Using .Net Core dll in standard .net Console app

后端 未结 1 551
-上瘾入骨i
-上瘾入骨i 2021-01-29 06:59

I have built a class library in VS 2017 using .NET Core 2.1. Now, I want to use that dll in a standard console app built in .NET framework 4.6.2.

When I refer to the .NE

1条回答
  •  清歌不尽
    2021-01-29 07:25

    How to resolve this?

    You cannot. At least not directly.

    • .NET Core can run assemblies targeting either .NET Core itself or .NET Standard
    • .NET Framework can run assemblies targeting either .NET Framework itself or .NET Standard

    So there is no way to bring two assemblies that target Full Framework and Core respectively together. Not in Core and not in full framework. (You might be able to find hacks and "but for me this works" solutions all over the place, but they are super brittle exceptions for their specific use case).

    You could switch your target framework of the .NET Core assembly to either .NET Framework, or to .NET Standard, or you could give multiple target frameworks to build a Nuget package that supports .NET Core and full framework.

    But if you need a .NET Core assembly and a .NET Framework application, you cannot use them together that way.

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