Visual Studio 2010: Could not resolve mscorlib for target framework '.NETFramework,Version=v4.0'

105,510

Solution 1

Microsoft Visual Basic for Applications Extensibility 5.3 (VBIDE) is the name of the devil!!!

Apparently this is a reference which my co-worker had somehow, but i didn't and because of this reference, EVERYTHING died. We discovered this because if you check "Show all files" on the specific project (which is a VB.NET project) you get the sweet References folder, which is normally not there for VB.Net project it's seems. Where the Tab failed us, the folder showed us one reference with a warning. Apparently this is something the compiler or VS2010 couldn't tell me but was exactly what was messing it up for us.

So, if you get this error when working on a project, "Show all files" so you get to see the References folder, and find out which reference could be causing your problems!

I'm glad it found this though, after more then 3 hours!! >.<

Solution 2

It could be that the path to your solution is too long:

Meaning:

C:\MyProject\Folder\SubFolder...

should be Under "256 Character".

http://wcfvs.blogspot.com/2011/04/could-not-resolve-mscorlib-for-target.html

I found this thread when I had the same issue but had no reference issues. I found the link above and it solved my problem. Hopefully this will help someone else who comes here with the same problem.

Solution 3

I was getting this error this morning. I just did the following:

  1. Rebuild the Project
  2. Closed Visual Studio
  3. Re-opened Visual Studio

and the error was gone.

Solution 4

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:

  • Go to the Solution Explorer and right click on the project name and select "Unload project".
  • Go to the Solution Explorer and right click on the project name and select "Edit YourProjectName.proj"
  • Remove every element with has something to do with your (web) service references. (Typically it contains text "service references")
  • Go to the Solution Explorer and right click on the project name and select "Reload project".
  • Now add your (web) service references again.

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.

Solution 5

i worked on my project saved the work and closed visual studio 2010. when opened again for working i got this error i just closed visual studio again copied the file where my project was saved and i pasted it somwhere else (in a file on my desktop) and i opened again the project with VS2010 and it was working.

Share:
105,510
F.B. ten Kate
Author by

F.B. ten Kate

None

Updated on July 09, 2022

Comments

  • F.B. ten Kate
    F.B. ten Kate almost 2 years

    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.