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.
Related
I don't understand why it appears given error : The type or namespace name "Storage" does not exist in the namespace "Microsoft.Xna.Framework" (assembly reference may be missing).
I try to download Microsoft XNA Framework Redistributable 4.0.
How to fix it?
You haven't given any information to your problem such as code you have written or references added so I'm sorry if this doesn't help. But, if you're using Visual Studio 2019 here is a video to help you add the entire framework to your program.
EDIT: If you already have the framework downloaded. What you need to do is right click your project on the right. then Add>Reference.. then search for Microsoft.Xna.Framework.Storage.
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 working on a small project involving a wpf-based UI program when I come to a intellisense problem. It constantly complains that several identifiers (class/method/property) cannot be found, and most of those are from another assembly. Similar issue has been asked by many other users of visual studio:
WPF assembly reference missing - project still building
Type or namespace cannot be found, when reference does exist
Getting "type or namespace name could not be found" but everything seems ok?
If the promble only happens on types in referenced assemblies I might just overlook it. But now even some types in the same assembly are determined 'missing' by intellisense. Today I created a new custom Window in this wpf project, and visual studio auto generated code for further use as follows:
public partial class ReceiveTest : Window
{
public ReceiveTest()
{
InitializeComponent();
}
}
Then intellisense told me that identifier 'InitializeComponent' cannot be found, and every control this window owns cannot be found either. This is really upsetting since it makes intellisense completely useless. Normally these 'missing' identifiers are declared in FileName.g.i.cs and managed by visual studio itself, however it seem visual studio somehow failed to recognize it.
Now I have done everything I can including solutions given in above links but failed again and again. Could anyone explain this problem and show me a way to solve it? I would be very very grateful.
P.S. I am using visual studio 2017 and PowerTool addon
Upgrading Test project from 2010 to 2017
Following this up on a recent problem with a test project on VS2017 after upgrade from 2010. Tried everything to get rid of the squiggly red and they wouldn't go.
Problem was that 'namespace.zone.section' had 'namespace' not found when it was there and seen by intellisense etc (and in some cases 'zone' or 'section')
Deleted sou files
Deleted project files
Deleted the references
Reapplied all after clean, restart, restart
server and all the above.
Still problem persisted.
So I deleted the test project (imported form 2010) recreated the project in 2017, copied all the original test classes into new project, added back all the other projects (supporting the tests), added moq etc back in. Only took about 20 mins.
And ... compiled and worked.
Conclusion was that the original project file (test project) had something in it that didn't get upgraded and screwed it all up. Anyway it is all fine now.
I post this so you don't have to wast your time.
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 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.