是否可以从.NET 5项目添加对.NET Framework DLL的引用? [英] Can I add a reference to a .NET Framework DLL from a .NET 5 project?

查看:2258
本文介绍了是否可以从.NET 5项目添加对.NET Framework DLL的引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft最近在Build 2019上宣布.NET的下一个主要版本将把.NET Core 3. *和.NET Framework 4. *统一为一个.NET平台,主要版本号为5。 / p>

我不太了解它,这是否意味着使用.NET 5可以添加对使用两种.NET版本编写的库的引用?



例如,一个.NET 5项目引用了两个程序集,一个针对.NET Core 3进行编译,而另一个针对.NET Framework 4.5进行编译(在本例中,因为它引用了一个.NET Framework库,我认为它只能在Windows上运行。

解决方案

它将与今天相同:您将可以引用.NET标准库。 .NET 5并不包含经典框架的所有内容,因此无法直接引用.NET 4.x程序集。因此,开始在.NET Standard中编写库。



但是,在.NET Core 2.0中,Microsoft实现了兼容性填充程序,该功能允许将旧程序集中缺失的tpyes类型转发到新类型。 。只要您的库不使用.NET 5不支持的任何类,您就可以放心。



请参阅此发布以获取更多信息。


Microsoft recently announced at Build 2019 that the next major version of .NET will unify both .NET Core 3.* and .NET Framework 4.* into a single .NET platform, which the major version number will be 5.

I didn't understand it well, does it mean that using .NET 5 I will be able to add references to libraries written in both version of .NET?

For example, a .NET 5 project referencing 2 assemblies, one that was compiled targeting .NET Core 3 and another compiled targeting .NET Framework 4.5 (in this case, as it references a .NET Framework library, I think it would only be able to run on Windows).

解决方案

It will be the same as today: you will be able to reference .NET Standard libraries. .NET 5 does not contain everything of the classic framework, therefore it won't be possible to reference a .NET 4.x assembly directly. Therefore start to write libraries in .NET Standard.

However in .NET Core 2.0 Microsoft implemented the compatibility shim that allows type forwarding of missing tpyes in old assemblies to the new type. As long as your library does not use any classes that are not supported by .NET 5, you're safe.

See this post or this for more information.

这篇关于是否可以从.NET 5项目添加对.NET Framework DLL的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆