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

前端 未结 21 2851
谎友^
谎友^ 2020-12-14 14:31

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

相关标签:
21条回答
  • 2020-12-14 14:53

    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.

    0 讨论(0)
  • 2020-12-14 14:58

    I had this problem in Visual Studio 2013 when going from .NET 4.5 to .NET 4.6.2. The problem project was a website project.

    Visual Studio automatically runs some tool which generates Reference.svcmap. The Reference.cs starts with:

    //------------------------------------------------------------------------------
    // <auto-generated>
    //     This code was generated by a tool.
    //     Runtime Version:4.0.30319.42000
    //
    //     Changes to this file may cause incorrect behavior and will be lost if
    //     the code is regenerated.
    // </auto-generated>
    //------------------------------------------------------------------------------
    

    Just picking the new .NET version caused Visual Studio to clean out the generated files and not fill the contents back. I tried all the solutions above but none worked. Eventually I picked .NET 4.5.1 followed by .NET 4.6.2 and the tool did run. The difference in the files was only the version number of the tool which was in a comment, so I could have recovered the files from GIT.

    0 讨论(0)
  • 2020-12-14 14:58

    I was migrating a vb.net project to VS 2015. I also had the same issue. The problem is not with the .Net framework, since I was able to create a new Project targeting the specific Framework Versions and it succeeded.

    In my case, the project was referencing FPSpreadADO and some other similar libraries. It worked fine once I removed those references.

    0 讨论(0)
  • 2020-12-14 14:59

    I got this error too. ("Could not resolve mscorlib for target framework '.NetFramework 4.5.1'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.").

    This happened when I changed the framework from 3.5 to 4.5.1 on a VB 2013 project. The solution was to remove all the references on the .vbproj file: all the references labeled Reference and COMReference groups.

    Of course just after doing this all kind of other errors appeared on the project.

    Then I started to copy them back, one by one in the same place, copying from a back-up in order to identify which between them were the problematic ones (I copied the ones related with the new errors I got in order to fix them), refreshing the project each time until the affected window visualized properly.

    It resulted they were some customized libraries references which created this problem. I hope this could help someone. Cheers!

    A Developer.

    0 讨论(0)
  • 2020-12-14 15:00

    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.

    0 讨论(0)
  • 2020-12-14 15:01

    I ran in to this problem today, and it proved to be caused of too long filenames in the project.

    This, in turn, was caused by some service references. When a service reference is imported or updated, visual studio generates .datasource files, where the filename is the fully qualified name. This means really long names in some instances.

    By googling around, I found hints that it was safe to delete these files. Check this or this out.

    Deleting these .datasource files removed the problem.

    0 讨论(0)
提交回复
热议问题