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
I have run into this before and trying a number of things has fixed it for me:
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"
}
}
Set Copy Enbale to true in netstandard.dll properties.
Open Solution Explorer and right click on netstandard.dll. Set Copy Local to true.
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.
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=\"Web\" /optionInfer+"/>
</compilers>
</system.codedom>
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.
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:
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
to <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
in the .csproj file.