17

I have followings projects:

.NET Core 2.0 Web Application

.NET Standard 2.0 Class library &

.NET Framework 4.5 Class Library.

I add reference of .net framework class library to asp.net core web api project. and it seems it works very well.

I am wondering why it's possible to add reference of .NET Framework class library project to ASP.NET Core Web API or MVC?

It's not supposed to allow adding only Standard or Core libraries references to Core projects? Is this core Web project with .NET Framework class libraries references still cross platform?

UPDATE

According to Phiter comment:

"If you import a .net framework library to your project it'll no longer be cross platform, but you can do it freely if you want to. They allow it because you might want to use .net core and still be on windows."

So if this is a reason, if I want to bind my project to .NET Framework and remain on windows why I use Core Web Project from the first place?

I thought we use core projects for cross platform ability and if not, the .Net framework is not a better option?

UPDATE

mason comment:

"Nothing funny: ASP.NET Core project doesn't have to run on .NET Core. It can also be run on .NET Framework.

Just because it's called 'Core' doesn't mean they're related. They could have called it ASP.NET FancyPants and had it run on .NET Core and .NET Framework and you wouldn't be as confused. Microsoft just sucks at naming things."

UPDATE (November 12, 2018)

A first look at changes coming in ASP.NET Core 3.0 - Fully leveraging .NET Core

As announced on the .NET Blog earlier this month, .NET Framework will get fewer of the newer platform and language features that come to .NET Core moving forward, due to the in-place update nature of .NET Framework and the desire to limit changes there that might break existing applications. To ensure ASP.NET Core can fully leverage the improvements coming to .NET Core moving forward, ASP.NET Core will only run on .NET Core starting from 3.0. Moving forward, you can simply think of ASP.NET Core as being part of .NET Core.

Customers utilizing ASP.NET Core on .NET Framework today can continue to do so in a fully supported fashion using the 2.1 LTS release. Support and servicing for 2.1 will continue until at least August 21, 2021 (3 years after its declaration as an LTS release) in accordance with the .NET Core support policy.

8
  • 1
    If you import a .net framework library to your project it'll no longer be cross platform, but you can do it freely if you want to. They allow it because you might want to use .net core and still be on windows, you never know right? Commented Dec 18, 2017 at 18:10
  • @Phiter So if I want to bind my project to .NET Framework and remain on windows why I use Core Web Project from first place? I thought we use core projects for cross platform ability if not, the .Net framework is not a better option? Commented Dec 18, 2017 at 18:20
  • 1
    The thing is: it makes no sense, but they will not remove your ability to do this kind of stuff because every developer has the right to do his own nonsense stuff. Commented Dec 18, 2017 at 18:22
  • 1
    Also keep in mind ASP.NET Core doesn't have to run on .NET Core. It can also be run on .NET Framework. Commented Dec 18, 2017 at 18:28
  • 3
    Nothing funny about it. Just because it's called "Core" doesn't mean they're related. They could have called it ASP.NET FancyPants and had it run on .NET Core and .NET Framework and you wouldn't be as confused. Microsoft just sucks at naming things. Commented Dec 18, 2017 at 18:30

2 Answers 2

9

This was just added as part of .NET Standard/Core 2.0. As long as the .NET Framework dll only references things in the .NET Standard, it will use type forwarding to the .NET Core implementations.

Sign up to request clarification or add additional context in comments.

6 Comments

This is the precise reason why the behaviour is supported. I've mentioned it several times in answers and comments, but I would recommend that the question OP takes a look at Immo Landwerth's videos on .NET Standard (youtube.com/…) as well as the url that this answer links to
I've still had issues with this. Even though I can have a project in .NET Core and another in .NET Framework. I need to reference the Framework Project for functionality in the .NET Core, but it breaks because the .NET Core project can't import those libraries
@BradenBrown what operating system?
@DanielA.White Windows 10. More specifically it is a Nuget package that it can't import. I may be doing something incorrect though
@BradenBrown perhaps it has dependencies that aren’t .net standard compliant
|
4

I do not know what made Microsoft allow referencing .net framework class library into .net core project but as a programmer, I am happy with this allowance.

You see allowing .net core application to reference .net framework libraries is useful in case you want to start with windows and are planning to go cross platform in the future.

We are in a stage where many useful open source libraries do not fully support .net core till the date of this post, masstransit is an example, so when I am developing a new software I will be using .net core project that depends on such libraries and I will update them later when they support .net core.

Comments

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.