You must add a reference to assembly 'netstandard, Version=2.0.0.0

后端 未结 17 2431
遇见更好的自我
遇见更好的自我 2020-12-02 08:23

The project is an ASP.NET MVC Web App targeting the .NET Framework 4.6.1.

All of a sudden (some NuGet packages were upgraded) I started to get the following error du

相关标签:
17条回答
  • 2020-12-02 08:32

    I have run into this before and trying a number of things has fixed it for me:

    • Delete a bin folder if it exists
    • Delete the hidden .vs folder
    • Make sure the 4.6.1 targeting pack is installed
    • Last Ditch Effort: Add a reference to System.Runtime (right click project -> add -> reference -> tick the box next to System.Runtime), although I think I've always figured out one of the above has solved it instead of doing this.

    Also, if this is a .net core app running on the full framework, I've found you have to include a global.json file at the root of your project and point it to the SDK you want to use for that project:

    {
      "sdk": {
        "version": "1.0.0-preview2-003121"
      }
    }
    
    0 讨论(0)
  • 2020-12-02 08:33

    enter image description here

    Set Copy Enbale to true in netstandard.dll properties.

    Open Solution Explorer and right click on netstandard.dll. Set Copy Local to true.

    0 讨论(0)
  • 2020-12-02 08:35

    I experienced this when upgrading .NET Core 1.1 to 2.1.

    I followed the instructions outlined here.

    Try to remove <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> or <NetStandardImplicitPackageVersion> section in the .csproj.

    0 讨论(0)
  • 2020-12-02 08:35

    The solution of Quango in is working but I prefer to resolve it by adding this code in my Web.config like new projects :

    <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs"
            type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
            type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
        </compilers>
      </system.codedom>
    
    0 讨论(0)
  • 2020-12-02 08:36

    You can add to your web.config in your project.

    It wouldn't work when you add it to projects web.config because it works with MVC.

    0 讨论(0)
  • 2020-12-02 08:38

    I was facing this problem when trying to add a .NETStandard dependency to a .NET4.6.1 library, and compiling it in Linux with Mono 4.6.2 (the version that comes with Ubuntu 16.04).

    I finally solved it today; the solution requires to do both of these things:

    1. Change <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> to <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> in the .csproj file.
    2. Upgrade your mono to a newer version. I believe 5.x should work, but to be sure, you can just install Ubuntu 20.04 (which at the time of writing is only in preview), which includes Mono 6.8.0.105.
    0 讨论(0)
提交回复
热议问题