We are currently migrating all our solutions from 2005 to 2010 (that's right, we're skipping 2008!). We are also changing our file structure to make some more sense (some common projects would be nested within specific projects etc etc).
This all means references need to be changed! Apart from that we are also setting them all to .NET 4.0. To accomplish this we've made a temp "GOD" solution with all 117 projects in the same solution.
I am doing this with one co-worker and until about 2 hours ago everything was going according to plan. However we ran into a problem with one of the 117 projects. This project refuses to "display" it's references, resources, services, and settings tabs within the Project Properties.
I get the following exact message:
Could not resolve mscorlib for target framework '.NETFramework,Version=v4.0'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.
Now this is annoying but it gets worse. My co-worker, when getting the same solution from subversion, CAN actually see and change the references and things. As a matter of fact, currently the project actually BUILDS on his machine. He committed the changes but I can't build this specific project, or see the references.
Which leads me to the simple conclusion, something has to be different on my client which is causing trouble! Suggestions online that I've seen are the following:
- Multiple .NET4.0 versions installed (this is not the case on my client)
- .NET v3.5 is not installed; v4.0 is trying to build v3.5 (3.5 is installed on my client)
- The registery key: OnlyUseLatestCLR is set and is screwing things up! (scanned my registry, this key is not present anywhere!)
See: http://connect.microsoft.com/VisualStudio/feedback/details/542789/
The only thing I haven't tried yet which I could do is repair .NET 4.0 how ever I highly doubt this is the issue since we have about 100 other projects which I can edit and build just fine. Both C# and VB.NET.
In most case it happened because of missing reference.
In solution explorer --> Reference -- > you can see the missing reference (in yellow) just add the reference you will be fine.
I had the same issue and after try most of the above, including reinstalling .Net 4.0 and rebooting still didnt go away.
Eventually solved it by moving my project tree lower down. ie. closer to the root of the drive. Turns out the directory and filenames were too long and I believe the references were being truncated and therefore couldnt resolve.
Problem came right immediately.
I had the same issue with a (web) service reference in my project. Both "Update service Reference" and "Configure Service Reference" did not work anymore.
Well lets just throw the (web) service reference away and create it again. No go! Same error message.
Solution: Edit the project file and remove everything which has to do with service references.
Instructions:
Problem solved (Well it was in my case).
My guess of what could have happened: I changed a class somewhere in my web service. The interface was not changed and Visual Studio somehow does not see the change(s). The (cached?) configuration does not match anymore and configuring/rebuilding/deleting the (web) service fails.
I ran into this issue today in Visual Studio 2017 on a project that I had apparently started out as a Universal Windows Platform application but ultimately settled on a Windows Forms desktop application.
Somehow, either through a branching mistake or commit problem in source control, some of the obsolete/discarded UWP XAML files, along with a "project.json" file wound up back in my project folder. VS would no longer build or launch my Windows Forms app with a similar error as reported by others above (e.g., "Could not resolve mscorlib for target framework '.NETFramework,Version=v4.7'").
After deleting all of the obsolete UWP junk (including "project.json", all the XAML files, and any other related nonsense) out of the project folder and reloading the solution, the errors went away and the project both built and launched successfully.
Hope this helps.
Check that the target framework in the project properties is set correctly - by default this is ".Net Framework 4.0 Client" - it may be that you require ".Net Framework 4.0"
see this thread that looks like the same issue
you may also want to review this article which relates to debugging an issue with the same symptom using reflector
I had a similar error in XamarinForms PCL project.
I found out that the error was about a reference of the project. I updated the xamarin.forms to the last version and for some reasons NuGet was not able to remove all references of the previous version from the project file (xml).
So, simply I deleted the following line from the project file and it worked!
Hope it helps someone...