Whenever I try to compile my VS2015 application, I a long list of errors like:
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
However, as soon as I double click the error to view the file, it opens the file, has a slight delay, then clears ALL the errors.
If I proceed to try and build again, I get the same list of errors and the process repeats itself.
UPDATE
I forgot to mention that I have tried:
following the advice in several other SO questions - to no avail
ensuring the dlls are set to copy to local
removing and re-adding references
deleting dlls from the application and adding them back
cleaning and rebuilding the application
restarting the application and my computer
What would cause this? How do I eliminate it?
Restart Visual studio
Remove the assembly reference and re-add it
Do a clean and re-build
Try install Microsoft.AspNET.MVC from nuget package manager
in my case it worked only after I run in the Package Manager Console following command
PM> Install-Package Microsoft.AspNet.Mvc
My environment was:
1) Visual Studio 2017
2) Freshly created Angular 4 app
3) MVC 6 as a back end
try download and copy System.Web.Mvc.dll into your project bin folder
I have a Web Application consuming a WebService. My web application has 2 projects - Startup and Other projects. I am able to build my solution and also run it without any problem in my local machine.
My Other project has a dll referenced named crypto. It is strongly named dll. Now I trying to publish my web app using File System. However it fails. Following are the errors.
The type or namespace name crypto could not be found (are you missing a using directive or an assembly reference)
From my output window
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "crypto". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
And finally it skips the Publish of website. Could anyone suggest me whats going on? Similarly I even had an WPF app and I was facing similar issue in Strongly Named dlls while creating Setup file. There I just put all the dlls in Special GAC folder and things worked. Here I am not sure.
Help would be appreciated.
Remove crypto dll from your projects, and add reference again , and be sure that crypto that you upload is exactly same as one you adding in reference. and then upload your project's dll again.
The type or namespace name 'Highscores2' could not be found (are you missing a using directive or an assembly reference?)
I've seen several threads on here with similar "type or namespace could not be found" problems, but the only root-cause was to make sure that the 'missing' namespace was also targeting the same framework.
In my particular case, "Target framework" is not set (and is even grayed out) in the properties of all of the projects, so that doesn't appear to be the issue.
The "using Highscores2;" is spelled correctly (copy/pasted from the namespace declaration) and the build order appears to be correct.
Additionally, the Highscores2 project builds fine on its own, and in a demo solution that came with the project, that solution actually builds just fine.
What other types of things (that I'm missing) can cause the "type or namespace could not be found" error?
You can have it as a project in the solution, but if you are trying to access it from another project that one must have a reference. You can open the target project's properties and check the "References" tab, and you should see an Add button.
Here is the MSDN page if it helps: msdn.microsoft.com/en-us/library/f3st0d45(v=vs.100).aspx
I've had a problem with this before with multiple projects. When I added a reference to the second project, in this case the one referencing HighScore2.dll, it was pointed to the /release build of the dll. However, in Debug /release isn't built, and so it couldn't find it. This may be a longshot, but if this is the case you can open up the csproj with notepad and edit the path for the assembly to use $(Configuration) in the path to point to the correct build configuration.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
This post was edited and submitted for review 9 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I have a WCF Data Service project built with Visual Studio 2010, which was working fine. All of a sudden, it didn't compile anymore. It was giving me messages like:
Error 7 The type or namespace name 'Services' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) C:\U...s\Visual Studio 2010\Projects...\DataService.cs ...
Error 8 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) DependencyResolver.cs 3 14
Error 10 The type or namespace name 'Web' does not exist in the namespace 'System.ServiceModel' (are you missing an assembly reference?)
Error 12 The type or namespace name 'DataService' could not be found (are you missing a using directive or an assembly reference?)
How can I fix it?
I have had the same problem, and I had to set the "Target Framework" of all the projects to be the same. Then it built fine. On the Project menu, click ProjectName Properties. Click the compile tab. Click Advanced Compile Options. In the Target Framework, choose your desired framework.
I had an issue with System.Linq not being recognized. The using statement had a red squiggly, etc. The way I solved it was to change my website to target dotnet 3.5, then switch back to the original targeted framework (4.0 in my case).
I found that this is caused by me having the same namespace name as class name (MyWorld.MyWorld = Namespace.ClassName).
Change your namespace to a name that is not the same name as your class and this will compile.
Source
I faced the same issue with an ASP.NET MVC site when I tried to use LINQ to SQL. I fixed the problem by:
Solution Explorer -> References -> Right-click on System.Data.Linq -> Copy Local (True)
I have experienced same problem with System.Data.SQLite. The source of the problem is the dll you have used should have same .NET version with your project.
For example if you have used (in my case) SQLite for .NET 4.5, your platform target should be .NET 4.5 too.
You can find platform target by: Project > (project name) Properties > Build.
Check to see that your target framework has the same .NET versions. I had the same problem and my class .NET was 3.5 and web solution had 4.5. I synchronised those, and then it worked :)
I had the same problem and tried all of the above without any success, then I found out what it was:
I'd created a folder called "System" in one of my projects and then created a class in it. The problem seems to stem from having a namespace called "System" when the .cs file is created, even if it is in a namespace of "MyProject.System".
Looking back I can understand why this would cause problems. It really stumped me at first as the error messages don't initially seem to relate to the problem.
In my case the problem was happening because the class I created had a namespace that interfered with existing classes. The new class A had namespace zz.yy.xx (by mistake). References to objects in another namespace yy.xx were not compiling in class A or other classes whose namespace was zz.
I changed the namespace of class A to yy.xx , which it should have been, and it started working.
FOR ANYONE WITH LINKED FILES: I had this problem and was using silverlight and the offending file that was throwing this error was a linked file.
The error from the compiler told me the error was happening in the project that the file lived in. It ended up that the error was NOT in that project, it was occurring in the project that contained the linked file. That project was missing a reference.
I encountered this problem while using Visual Studio's Git integration to manage the project. For some reason the Windows Phone 8 project would compile just fine when targeting x86, but when I set it to target ARM, it would fail compiling with an error indicating that "Advertising" didn't exist in the Microsoft namespace.
I ended up resolving the issue by removing the Microsoft.Advertising.*.dll reference and adding it again.
I experienced the same errors. After I discovered my project had the wrong Assembly name (I copied files from a different project and the namespaces got a little confused), and changed it back, the project compiled nicely.
I got a very similar error message that was caused by inadvertently having made a duplicate of a class in another project of my solution. Deleting the duplicate fixed the issue
And if all else fails, such as ensuring that the target frameworks are the same, and you are dealing with a WPF class library in VS2010, simply restart Visual Studio. That did it for me.
In my case there was no change in projects, it just stopped to compile and with "type or namespace name XXX does not exist" and in the complaining class itself intellisense for that XXX namespace/class works fine.
The problem was in references indeed!
Steps to reproduce:
Solution has ProjectA, ProjectB.
ProjectA references to third party log4net and it is marked Copy local: true.
ProjectB references ProjectA and does not have reference to log4net.
Solution compiles fine.
Change in ProjectA: reference property for log4net to Copy local: false.
Clean bin and obj folders.
When you compile, ProjectA compiles but ProjectB complains about not finding ProjectA namespace.
This is because ProjectB bin folder is missing third party library (log4net in my case)!
In this case solution would be -
make sure that third party libraries references are set to Copy local: true
or
add path to such libraries in project properties under reference path.
I am referencing Microsoft.CommerceServer.Runtime.Orders and experienced this error. This project is old and has Target framework .NET 2.0. In output I had this error:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference "Microsoft.CommerceServer.Runtime" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "Microsoft.CommerceServer.Runtime" or retarget your application to a framework version which contains "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
I simply changed the target framework to .NET 4 and now it builds.
I recently needed to do a System Restore and it caused several of my files to change/disappear that I had been working on since the restore. Some of those were DLL files. I used Source Control to retrieve the entire project but I still had a similar issue as above. I found this answer that described you may need to remove a DLL and readd it to get your errors fixed. This was the case in my scenario.
Removing WebMatrix.WebData and readding it as well as adding in WebMatrix.Data fixed my error of The type or namespace name 'Data' does not exist in the namespace 'WebMatrix' ....
Delete the .refresh.dll file if you are under source control. Then rebuild. It should work.
This worked for me
I have tried all the suggestions below but still no joy.
I'm now trying a console application, and let me explain exactly what I'm doing.
I create a new console project in VS 2010
I add a number of references (dll's) some that aren't mine such as Castle.Winsor and N2 CMS dlls
in the console app I can add using statements indicating I am using name spaces within the referenced DLLs
I start writing code.
As soon as I compile all the code that uses the referenced DLLs immediately complains with "The type or namespace name '' could not be found (are you missing a using directive or an assembly reference?)"
I have tried setting the dlls to copy to local always, I have copied the DLL into the same directory, I have tried added reference by project and adding a reference to the DLL's themselves
I don't get this problem with a web application project or a ASP.net project they always work fine, only something that is compiled to an EXE like a console app or windows service.
there must be something I'm missing or I would have got this working by now.
Change the project Target to a non Client Profile target. Right click the Project and select Properties, you should see a list of Framework versions. As you are using VS2010, the Console project you've created by default targets .NET Framework 4.0 Client Profile, change that to .NET Framework 4.0.
Check if Copy Local is set to true for the referenced assembly.
First, as to your question, its hard to know exactly what you're doing wrong, but from the fact that you're using an underscore in an assembly name (and probably in namespaces and type names), it suggests you're rather new to the .NET world.
This suggests that you're adding references to other projects in your solution by browsing to the compiled assembly, rather than by adding a Project Reference. When adding a reference, you must select the Project tab rather than browsing for the assembly.
Even if you don't believe this is the issue, remove all references and re-add project references to make absolutely sure. Assumption, asses etc.
Once you've done that, I'd strongly suggest remove all the underscores from your types, namespaces and assemblies. You might want to go read the framework design guidelines, too.
Open your .Proj(Windows service project file) file in notepad and check whether your assembly location(data_object) is the same which you are pointing.
When you open .Proj file in notepad you can check for,
Project reference,
<ProjectReference Include="C:\StackOverflow\StackOverflow.csproj">
And if you giving dll or exe refrence then
<Reference Include="StackOverflow, Version=1.0.0.0, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<ExecutableExtension>.exe</ExecutableExtension>
<HintPath>C:\StackOverflow\bin\Debug\StackOverflow.exe</HintPath>
</Reference>
I suggest you to give exact location including drive name like above example.
Other option you may try,
1. Clean and rebuild
2. Add Project reference if you already tried dll reference
3. Check whether the folder (referred assembly location) is Read Only then remove it.
In VS 2019, I had two projects, one C++ and other one C# Console in one solution file. When tried to add a dll reference through "Add reference", I was not able to see Browse button in "Reference Manager" window, to select dll file.
But when I created only C# Console app inside solution then I could add dll reference.