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

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

问题描述

微软最近在 Build 2019 上宣布,.NET 的下一个主要版本将把 .NET Core 3.* 和 .NET Framework 4.* 统一为一个单一的 .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.

我不太明白,这是否意味着使用 .NET 5 我将能够添加对用两个 .NET 版本编写的库的引用?

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?

例如,一个引用 2 个程序集的 .NET 5 项目,一个是针对 .NET Core 3 编译的,另一个是针对 .NET Framework 4.5 编译的(在这种情况下,因为它引用了 .NET Framework 库,我认为它会只能在 Windows 上运行).

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).

推荐答案

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

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.

但是,在 .NET Core 2.0 中,Microsoft 实现了兼容性垫片,允许将旧程序集中缺少的 tpyes 类型转发到新类型.只要您的库不使用任何 .NET 5 不支持的类,您就是安全的.

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.

请参阅此帖子this 了解更多信息.

See this post or this for more information.

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

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