I am using the MagicLibrary for a few components. I knew it was written in Visual Studio 2003 and recompiled it in Visual C# Express 2010. It compiled just fine and I could see the library in the folder.
I then created a new project in Visual C# Express 2010 and added the components MagicalLocalLibrary.dll to the Toolbox. They appeared fine with no errors. I put in a control from the Toolbox to my form, and it seemed fine. I then debugged (to see if any errors would occur) and I saw that the reference MagicalLibrary disappeared and I got the error:
The type or namespace name 'Crownwood' could not be found (are you missing a using directive or an assembly reference?)
The thing is that, the reference shows fine under References in Solution Explorer but I can't import it with using or use it in the code (simply is not listed in InstelliSense either) but if i go into the Object Browser and choose "My Solution" it is not listed. I can click on the Reference in Solution Explorer and just change the Copy Local property to True or False, then it will appear in the Object Browser but whenever I debug my project again it disappear.
Any idea why it does this? Thanks in advance.
Check that you are using the .Net 4 framework and not the client profile version
You find that setting when you right-click on your project, choose properties. And under application there is a setting for target framework. If you have chosen the .Net 4 framework Client Profile, then this behavior that you described can happen
I ran into a very similar issue once. In my case the problem turned out to be a missing dependency for the "vanishing" namespace's assembly. What finally gave me the information I needed was the suggestion in this StackOverflow answer to raise the MSBuild output verbosity level. After raising the verbosity setting the IDE should give you a more specific reason why the compilation fails.
Related
I am using the System.Compression.ZipFile.dll in a Unity project, and have added the reference to both the the Visual Studio project and within the Unity Editor, and the code compiles and runs as expected without issue.
However, whenever Unity compiles the code, the DLL reference is removed from the Visual Studio Project.
As a result, compiling within Visual Studio afterwords will have namespace errors. These errors are only in in Visual Studio, as the Unity editor does have the reference when it actually compiles the code.
These errors are fixed by re-adding the DLL reference to the solution. I would like to stop the errors from showing up in Visual Studio, as they are rather annoying.
How do I prevent the reference from being removed from the Visual Studio Project when Unity actually compiles the code?
If it helps I am using Visual Studio Community 2015, and the Unity Editor 2018.2.14f1, on Windows 8.1, with .NET version 4.7.1
EDIT:
My mcs.rsp file contains: -r:System.IO.Compression.FileSystem.dll
based on a unity forum thread. This is interesting as it is not the expected DLL, and yet it still works.
Adding -r:System.IO.Compression.ZipFile.dll will cause:
error CS0006: Metadata file `System.IO.Compression.ZipFile.dll' could not be found.
The relevant errors are:
CS1069 The type name 'ZipFile' could not be found in the namespace 'System.IO.Compression'. This type has been forwarded to assembly 'System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, Consider adding a reference to that assembly.
Error CS0006 Metadata file ProjectFolder\Temp\bin\Debug\Assembly-CSharp.dll' could not be found
Unity is correctly configured to use .NET 4.x
The behavior you are getting is expected.
Let's go through the official way to achieve what you're looking for:
Copy your DLL in Assets directory, optionally, with its associated XML for IntelliSense, and the PDB file so that Unity generates an MDB file out of it
Unity rebuilds the project and the generated Visual Studio solution
Since step 2 re-generates the Visual Studio solution, every customization you've done to it are lost, exceptions for manually added existing projects for being able to step through them when debugging your game.
Note that nowhere in the official instructions you are expected to add references to the generated projects, it's done automatically and manual changes are lost anyway as laid out in previous paragraph.
But you are getting errors, right ?
It's hard to tell without more information.
Suggestions:
1.
Try the official instructions and if it doesn't work, edit your question to add the relevant errors so people can further try to help you.
2.
Do your DLL matches the framework version of Unity ?
In some cases it can produce funny errors otherwise.
When I look at the contents of System.IO.Compression.ZipFile, it's only for .NET 4.6:
Do your player settings match .NET 4.6 ?
This issue happens when you use some of the new features in C# 7 or C# 8.
In my case, I was working on an older project, built on .NET framework 4.6 and switched some using blocks to simplified using statements. E.g., instead of
using (var resource = new ExpensiveStuff())
{
//whatever
}
I did:
using var resource = new ExpensiveStuff();
//whatever
The compiler silently allowed me to do this but the next build failed with the CS0006. It took me an hour to figure that out. I was about to re-install my Windows...LOL
I am building a custom code coverage app using the Microsoft.VisualStudio.Coverage.Analysis class.
I have added the reference to the dll to my solution already and when I start typing the using statement at the top of my class Visual Studio is predicting the correct names, e.g. after typing "Microsoft." "VisualStudio" will be displayed in the suggestion box, the same thing happens with the next two levels, Coverage and Analysis.
But the second I try to build the project I get the following error:
the type or namespace name 'visual studio' does not exist in the namespace 'microsoft'
I've no idea why this is happening so any suggestions would be great
I should have checked the warnings in visual studio, they had the real error details, the project had to be built against .net 4.5 and not 4.0.
Once this was changed the project built correctly.
I've added the toolkit.dll as a reference, inherited KryptonForm instead of Form, successfully built the application, everything is working fine, but designer mode fail to display the form. I am getting this error:
Could not find type 'ComponentFactory.Krypton.Toolkit.KryptonForm'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
I found the issue: I renamed the dll thinking that will not affect in any way the application, and it didn't !
But somehow affects the designer: when I renamed the dll back to ComponentFactory.Krypton.Toolkit.dll Visual Studio's designer worked aswell. I am curious why behaves this way
In C#, I made a ClassLibrary that has one Namespace and one Class.
I saved it and build it.
in other Projects, when i use it, I add it to my references by browsing to the .dll location.
But The Problem is that its name is not showing up in the Intellisense.
i.e when I: using ... my dll doesn't show ..
I'm Importing the library to a ConsoleApp.
both of the App and the library target Framework is .NET Framework 4.0
and I made their Assembly Version 4.0.0.0 so they're the exact same.
is there a setting or something that I'm missing ?
how can i make it pop up ?
I'm using VS2010 Professional
Thank you for your help
Maybe this be usefull, I was having a similar issue, I have a Web project, add the reference to a Class Library by selecting the project, but if I made a change on the class library, I canĀ“t see that change on the intellisense of the Web Project, after try many things, I see that in the recently added reference, the value of the option "Local Copy" was set "True", then I change it to false and everething works!
I had a similar issue but in my case it was a property on the class. If you go to the file properties and look for a Build Action. Somehow mine was set to Content it had to be set to Compile.
I am using Visual Studio 2013. I hope this helps someone else.
Is the namespace for your assembly different than the namespace for your currently open project? I've had times when the current project and an assembly share the same namespace path the intellisense can mess up.
In general, Visual Studio is pretty good about intellisense generation, especially for C#. But sometimes there are some interesting conditions regarding ambiguities, and especially mixing project types where it just doesn't quite work.
Placing your content in the same namespace makes me wonder if you've actually fixed the problem (it may just be autocompleting the namespace in the currently loaded project rather than the assembly), but if it allows you to continue working, then go with it!
Right click on project on which you add reference of your dll/project select menu project dependancies and select/MarkCheckBox for reference project/dll. then it will work fine.
If the class library project had its name changed after creation, then intellisense may fail finding it due to directory issues, I believe.
I created my class with the generic "ClassLibrary1" or whatever, and then later changed the default namespace, class name, and project name inside of VS2017. I closed VS2017 and changed the directory name to match my default namespace, and then re-associated the project file in VS2017, and then re-added the reference in my main project file.
All seems to be fixed now.
I recently migrated a solution from VS2005 to VS2010.
The solution is composed by about 20 project. One of them is in VB.net, the others are C#.
In VS2005 everything was fine, that is I was able to reference the VB.net project into the C Sharp projects. Now I cannot anymore.
The strange thing is that when I open in the editor a C# class referencing the VB.net dll, I get a compile error that sounds more or less like this:
"he type or namespace name 'VB.netProject' does not exist in the namespace 'Solution Namespace' (are you missing an assembly reference?)"
... and no, the assembly reference is there indeed!
However, when I close the files in the editor and try to compile again, the operation succeeds and the executable that I get works perfectly like it did in VS2005.
Is there a way I can manage to see the VB.net component in the editor? I am sure I am missing something, but I don't know what! :-)
Many thanks in advance for your help,
John
Unfortunately the visual studio sets (after the migration) the target framework to .NET Framework 4 Client Profile. If this target framework is set, some namespace could not be found (=> because the client profile doesn't contain this classes). Please verify, if your project has set this target framework. You will find this setting under the project properties.
Kind regards, patrick