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

前端 未结 21 2853
谎友^
谎友^ 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:47

    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!! >.<

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

    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.

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

    I had this problem today and the solution was to manually edit the Resources.resx file manually.

    My Resources.resx file looked like this:

      <data name="SomeString" xml:space="preserve">
        <value>I am a string</value>
      </data>
      <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <data name="MyLogo" type="System.Resources.ResXFileRef, System.Windows.Forms">
        <value>..\Resources\MyLogo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
      </data>
      <data name="Open" type="System.Resources.ResXFileRef, System.Windows.Forms">
        <value>..\Resources\Open.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
      </data>
    

    Turned out that Visual Studio didn't like the two <data> elements after the <assembly> element, which is strange considering the fact that Visual Studio added them there itself. My problem was solved after I moved them before the <assembly> element:

      <data name="SomeString" xml:space="preserve">
        <value>I am a string</value>
      </data>
      <data name="MyLogo" type="System.Resources.ResXFileRef, System.Windows.Forms">
        <value>..\Resources\MyLogo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
      </data>
      <data name="Open" type="System.Resources.ResXFileRef, System.Windows.Forms">
        <value>..\Resources\Open.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
      </data>
      <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    
    0 讨论(0)
  • 2020-12-14 14:51

    Happened to me in the Resource Editor.

    Cause: I was importing some .Targets file, which defined a property called AppConfigFile, which probably over-wrote some internal property of the same name:

    <PropertyGroup>
      <AppConfigFile>...</AppConfigFile>
    </PropertyGroup>
    

    Fix: Renamed property to some other name, and the problem went away.

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

    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!

    <Error Condition="!Exists('..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.2.3.1.114\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets'))" />
    

    Hope it helps someone...

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

    I had the same issue when the source directory was read only. If I sync my workspace with our version control server (Perforce), it will make all of the directories read only by default unless I select that I am checking out the directory for editing. Sometimes I am lazy and don't do this since I am the only person working on some of these projects at any point in time. But this error goes away clear the read only flag.

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