.NET - Project Won't Build - c#

I have a WPF/ASP.NET project which I haven't worked on for a while (ResourceBlender.NET - http://resourceblender.codeplex.com/). The project contains a DataLayer and a Core layer, these are both used by the WPF application and ASP.NET project in the solution.
If the WPF project is set as the startup project and I try to build the application, I get "The type or namespace name 'whatever' could not be found (are you missing a using directive or an assembly reference?)".
The error list shows these when I try to build, run or debug, but double clicking and going to the error shows no actual errors in the editor and everything is highlighted as normal.
The ASP.NET project builds fine. I'm absolutely clueless on this one, as there are no obvious errors to fix - could it be metadata somewhere?

Check that all assemblies does not target the 3.5/4.0 Client Profile (It is probably the WPF application that is the culprit). This will cause exactly the error message you're describing.

This type of thing is really hard to debug without being able to see your solution setup, but here are the things I would try:
Expand the references in your WPF project, make sure they are all resolving
Double-check that none of your references have "specific version" set to True and point to an old/nonexistent version
Do a "Clean" on your solution, close VS and delete your bin and obj directories, etc. to clear out potentially old copies of dlls that may be messing up your build
Good luck!

Try the following:
Right-Click on the solution on do a "Clean Solution"
Try to build each project separately
Check the references on your projects for missing assembly references

Compile issues like this can be overwhelming. It's usually best to troubleshoot one project at a time as suggested in these tips:
5 Debugging Tips for a Solution That Won't Compile

Actually read the Output window text.
often errors or warnings that are pertinent appear in there but aren't obvious when following the Error List window links.

Related

The type or namespace name 'Membership' does not exist in the namespace 'Microsoft.AspNet'

I'm trying to maintain an application that contains the following line in several different files:
using Microsoft.AspNet.Membership.OpenAuth;
I've tried everything I could find. Removed and re-added the reference; cleared the MEF cache and rebuilt; added a different file as a reference. Nothing works. It's bizarre because VS2017 doesn't report this error in the Error List window, but it does show up in the Output window. Anyway, can someone please suggest a possible solution that maybe I haven't tried yet? Thanks.
I was able to compile the project and I will describe how I got it.
1 - I delete all using Microsoft.AspNet.Membership.OpenAuth; and build project.
2 - After build the code show many errors I use the resource of VS2015 help fixes errors on code Show potential fixes and set again using Microsoft.AspNet.Membership.OpenAuth; build project.
3 - Set a new framework 4.6 and build project.
https://drive.google.com/open?id=0B4aywYtmwk6lT1dDNnIxRmtQcUk

WPF error : The name does not exist in the namespace

I'm getting this problem building a WPF project
The name does not exist in the namespace
Everything I’ve looked at says you should
Change the namespace and the project name, build, change them back
Change the build from 86 to 64, build, and back Tried removing the
reference and letting ReSharper re-instate the reference Tried
excluding the file, build, then include the file again
None of the above worked.
I have checked that each referenced class has only one instance of it throughout the whole solution – ruling out named duplicates
The references in question are all references within the one DLL – all namespaces within this dll so it’s not like there is a cross dll issue of any sort.
Your thoughts or suggestions at this point are appreciated.
I to assume that You have this error in XAML file.
I thing it is very common problem with WPF and Visual Studio 2015.For example I have this error when I use DevExpress dlls
My suggestions is to try this:
Restart Visual Studio - it is weird but frequently it works. I don't now way it works.
Use F5 and run the program instead of build them (F6). Sometimes when You compile app the error disappear and app runs. It is also weird, but in my case it works
This not resolve the problem but it helps exclude the problem with IDE

Type or namespace name does not exist in the namespace - yet the namespaces do exist

A project that I've been working on for a long time without any problems suddenly started throwing errors such as
The type or namespace name 'xxx' does not exist in the namespace 'yyy' (are you missing an assembly reference)?
In this case, the namespaces were all core .Net libraries such as System.Data, Linq, and IO that I've been using without any problems.
I've worked through all of the issues in this question such as making sure all the projects in the workspace are using the same version of .Net for the Target Framework setting.
I removed all the libraries in question and re-added them but the problem persisted. I doubt they libraries themselves are corrupted as I reference them in other projects within the solution.
After rolling back through my work with TFS I managed to work out what I'd done that had created this error: I'd added a folder called "System" to my project and put a class file in it.
This is an easy issue to reproduce: create a project, add a folder called system to it (it will still compile at this point) and then create a .cs file in it, that's when all the fun errors will occur.
The problem stems from the name of the "System" folder which leads to any files created in it being under the namespace ".System".
I can understand why having a folder / namespace called "System" would cause problems now but I think it would help if Visual Studio warned when creating a folder / namespace of such a name to stop this problem happening in the first place. I've logged a bug with MS, at least having this logged might help any other people who have made the same mistake as me!
I had the same issue after my system shut down unexpectedly and even though VS tried to restore, the problem popped up.
I had two projects in my Solution Explorer. To solve this, I right-clicked the project that was associated with the error message and selected 'Build'.
After that, the issue was resolved.
Just to add that the problem was permanently solved after I added a reference to the 'project' from the other 'project'.
I renamed the namespace of the file I was referencing from myproject.shared.constants to myproject.SOMETHING.shared.constants
After that It suggested "use myproject.SOMETHING.shared.constants" as suggestion. I renamed it back to myproject.shared.constants and then it worked.
Try to Clean and Then Rebuild the dll file .I was experiencing the same problem tried different suggestions from internet but none of them work.But it will. In case you don't know how follow these steps:
open your dll project file.
2.click on solution Explorer Right click on Your Dll Project Name you will find Clean and Rebuild Option.

Visual Studio saying name doesn't exist in current context

I am calling a static method on a class like
Foo.bar()
Visual studio's intellisense recognizes Foo and autocompletes bar for me (it highlights Foo and everything like it is working fine). Everything looks fine until I go to build the project, and it throws an error saying the name Foo doesn't exist in current context.
I am using this static method call in other files, so I know the class is ok. The situation is too big to post code, so I am mostly looking for reasons to start looking into that would cause intellisense to function normally but get errors on compile like this.
I've seen this error caused by differing versions of the .NET framework in the different projects. The Class Library I built was 4.5 and the application was 4.0, but the only error it gave was namespace errors. Changing the framework version on the class library and rebuilding it, then the application, resolved the error.
This can occur when namespaces, classes and variables become tangled when they have the same name. I have suffered with this before. Intellisense told me I was right, the compiler told me I was wrong! I trusted the compiler!
You have 2 options that I can think of
Search your code for Foo, and see it it is being used for something other than the static class.
Fully qualify the Foo.bar() call. MyApplication.This.That.Foo.bar();
Do it in that order...it's better to elegantly resolve the issue so you can just call Foo.bar() as this is more readable and maintainable than having MyApplication.This.That.Foo.bar(); all over the place!
In my case I was missing a } at the end of one of the methods in the middle of the code which was causing the program not see the rest of the code and complain about the Methods I have defined after that point.
Old thread I know, but I've encountered this issue when referencing a static method from within a unit test project - intellisense said the method was there, but when I tried to build/run the test (in Debug mode) I got the error 'name doesn't exist in current context'. In order to fix it I had to rebuild the project containing the referenced static method in Debug configuration (it had only previously been built in Release configuration) - after this the test built and ran OK.
I know this is a bit old topic, but I just experienced the same and for me it was because the file was not actually included in the solution.
I properly happened because I had renamed the class and then the file, which caused Visual Studio to still know the class and the namespace, but the compiler did not get the file as the renamed file was not included.
Consider doing a Clean and then a Build on the project with the problem. It is possible for the editor and Intellisense to correctly discover the class, while the compiler works with files that are out-of-date. (I had this same problem, and that's how I resolved it.)
this is an old article I know, but I just encountered this issue and has been puzzling me for couple of days, and eventually got to it: click on the class file, in Solution Explorer, then look at the Properties tab; make sure Build Action is set to "Compile".
Adjust the related file. If the error code in Default.aspx.cs, you need to change the top line in the file Default.aspx as below:
Replace "CodeFile=" with "CodeBehind"
Hope this can help.
-Thanks, Thai_FUV
I have run into this probelm a few times and so when I do, the first thing I check is if the assembly not recognized has any Nuget packages. In my cases they always have and I simply forgot to install the same packages in the assembly of which the reference to the un-recognized assembly is in. A re-build command and problem fixed. I hope this helps someone. This same error message can be given for multiple things so this particular case, may not apply. If you have not used Nuget than I would suggest trying the other answers
I also was running into this issue creating a data access layer and had static methods being called with the same symptoms: Intellisense finding it but not the compiler. I tried many of the above, including fixing the .Net version.
When adding the source files to the project I also changed the namespace.
With the file with the issue, I forgot to change the namespace to match when it was imported at another time.
Closing all tabs of MonoDevelop. Then Closing MonoDevelop. Finally opening MonoDevelop again solved the problem for me.
Mine was a little more convoluted solution. Project A referenced projects B and C: both references had Copy Local to true and both produced assemblies with identical names. When building the referencing project, the output assemblies from projects B and C were copied and one overwrote the other because they had the same name. VS was then looking for the references within the build directory and only found the assembly that had "won."
In my case I had to reload the project that was marked "missing".
Project > Unload Project
Project > Load Project
Clean, Build Solution
My solution to this problem that occurs every now and then:
Find the class that is giving you problems in the Solution Explorer and "Exclude From Project"
Rebuild that assembly (let's call it "A")
The project that used the file ("B") will ask you to "Reload" project, wait
Add the file back into assembly A, that you just removed it from, and rebuild
Now, reload project B
Then the file was found in VS and all was well.
Changing the id of the control resolved the issue for me. Apparently the id of the control existed in another part of the solution.
In my case, I was missing the following lines in my csproj file
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
Once I added this, I could see the variables while debugging

VS2010 C# missing project dll during build

I have problem with build in VS2010. I´m trying to develop small Prism, MVVM application.
I added new project "Toolbar" to my solution "MyApp" and during the build I get following error (propably project´s dll is not created for some reason):
Error 2 Could not load referenced assembly
"C:\net\projects\MyApp\MyApp.Modules.Toolbar\bin\Debug\MyApp.Modules.Toolbar.dll".
Caught a FileNotFoundException saying "Could not load file or assembly
'C:\net\projects\MyApp\MyApp.Modules.Toolbar\bin\Debug\MyApp.Modules.Toolbar.dll'
or one of its dependencies. The system cannot find the file
specified.".
C:\net\projects\MyApp\MyApp\ResGen MyApp
I´m quite new to VS2010 and C# so I really don´t know what happend, wheter project dll is missing because of some mistake in source code or why this can even happend? I also don´t know how to find such a mistake in source code, because VS shows up only the error mentioned above. Dependenies of the project should be ok i guess, file MyApp.Modules.Toolbar.dll really doesn´t exist in any folder on my hdd.
The problem was the bad class name defined in xaml of Toolbar project (UserControl x:Class="BAD CLASS HERE").
After many googles for a similar problem where I had at one time toyed with using open office in a .net project and then all my aspx pages had the blue squiggely line saying cli_uno couldn't be found which was referenced no where and in none of my project or lib files.
I deleted all the bin folders, a dll referencing it was hiding in one of them and making vs2010 freak out.
I realize this isn't the exact solution to the above but there isn't much out there for this error and it is a head scratcher and deleting all the bin folders worked for me so it's something to try.
You provide too litle information, so I'll ask some questions (and some possible fixes):
Is the file at the specified path to begin with?
If not, is there a project you need to build to create the dll?
If there is such project, does it build the .dll where yours is looking for it -- if not, you either need to copy it by hand or set up a post-build process to do the copy automatically after each build
If there is no such project, do you have the .dll itself somewhere. If yes, you need to copy it to the correct location.
If the .dll is at the correct location, is there some protection preventing the other project to access it?

Categories

Resources