0

I have the following Problem. I try to write a Class Library for my ASP.NET MVC 5 Project.

So I want to add the NuGet Package for the Entity Framework 6.2.0 and the System.Web.dll.

My Class Library has the Property:

Target framework: .NET Standard 2.0

My ASP.NET MVC Project have:

.NET Framework 4.6.1

So when I try to add the System.Web.dll I become the following error:

enter image description here

When I change the Target framework in my Library to .NET Standard 1.6 I can add the System.Web.dll but I become the Error:

enter image description here

I asked Google for the .NET Standards and found this Table

enter image description here

So I think .NET Standard 2.0 work with 4.6.1. And in my ASP.NET MVC Project I can add Entity Framework 6.2.0 and System.Web.dll so why I cant do this for my Class Library?

P.S. I only see .NET Standards in the porperty window.

enter image description here

2
  • EF6.x does not support ".NET Standard"-only environments, that's why it's breaking. Unless you need to target non-Windows platforms you should switch back to ".NET Framework" instead of ".NET Standard". Commented Feb 2, 2018 at 7:48
  • @Dai and how I swith back to .NET Famework?. In the property window i have only a list of .NET Standards no .NET Framework Commented Feb 2, 2018 at 7:50

1 Answer 1

4

So i think .NET Standard 2.0 work with 4.6.1.

A .NET Standard 2.0 library can be consumed by a .NET Framework 4.6.1 library.

However, a .NET Standard 2.0 library cannot reference a .NET Framework library, such as System.Web. It is possible for a .NET Standard 2.0 library to reference a .NET Framework library, but only in compatibility mode. It is recommended to use compatibility mode only for cases where a .NET Standard option is not yet available. Since we know that System.Web (and many other .NET Framework namespaces) will never be released on .NET Standard, you should not reference it from a .NET Standard library.

.NET Standard is for portable libraries that need to run on multiple platforms (such as .NET Framework and .NET Core). If this is simply an application layer that will never be used outside of your application, you should have the same target as your ASP.NET MVC Project (.NET Framework 4.6.1).

You can switch by manually changing the target in the .csproj file.

<TargetFramework>net461</TargetFramework>
  1. Right-click on your project node in Solution Explorer and click Unload Project.
  2. Right-click the project node again and click Edit <projectName>.csproj.
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for you anwser. I have add a screenshot to my post. In the property window i dont have .NET Framework to select only .NET Standard?
i dont have a .csproj file in my Clas Library Project?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.