.NET Standard DLL 二进制文件与 .NET Framework 二进制文件兼容吗? [英] Is a .NET Standard DLL binary compatible with a .NET Framework one?

查看:41
本文介绍了.NET Standard DLL 二进制文件与 .NET Framework 二进制文件兼容吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个作为 .NET Framework 4.6.1 构建的实用程序库,并被各种 .NET Framework 应用程序引用.

我现在想创建一个新的 .NET Core 应用程序,因此我想将实用程序库转换为 .NET Standard 2.0,以便它可以被两种类型的应用程序使用.

如果我只是打开库的源代码,将目标更改为 .NET Standard 2.0 并重建它(假设它只使用 .NET Standard 中可用的 API),我是否可以将新程序集放入替换现有的应用程序,现有的应用程序是否仍然有效?或者是否需要针对新版本重新构建应用程序?

更普遍的相关问题是,为 .NET Standard DLL 生成的元数据与为 .NET Framework 生成的元数据有何不同,以及它们如何/是否会影响程序集解析器?

(为了抢先评论为什么不试试看",我想知道这是否是受支持的场景,而不仅仅是技术上它是否适合我)

解决方案

.Net Standard 是(但不限于).Net Framework 之间的兼容横截面和 .Net Core

这样想

或者,一张比较标准的宣传图

.Net Framework 中有很多东西在 .Net Core 中没有多大意义.例如 Windows 特定的东西.

但是,您可以做的是使用

回答您的问题

<块引用>

如果我只是打开库的源代码,将目标更改为.NET Standard 2.0 并重建它,我可以将新程序集放入替换现有的应用程序,如果现有的应用程序仍然工作?或者是否需要针对新的应用程序重新构建应用程序?版本?

据我所知,需要重建,试试看会发生什么,然后让我们知道.

有很多事情可能使这不起作用.

<块引用>

更普遍的相关问题是,在与 .NET 相比,为 .NET Standard DLL 生成的元数据框架一,它们如何/是否会影响程序集解析器?

不完全确定您的意思,但是在重建时它会解决相同的问题.

<块引用>

(为了抢先评论为什么不试试看",我想知道如果这是一个受支持的场景,而不仅仅是技术上是否可能为我工作)

据我所知或可以研究,不支持仅更换组件.不过,也许其他人在这里有更多信息.

I currently have a utilities library built as .NET Framework 4.6.1 and referenced by various .NET Framework applications.

I now want to create a new .NET Core application and therefore I want to convert the utilities library to .NET Standard 2.0 so that it can be used by applications of both types.

If I simply open the source code for the library, change the target to .NET Standard 2.0 and rebuild it (assuming that it does only use APIs available in .NET Standard), can I just drop the new assembly in to replace the existing one and should the existing applications still work? Or would the applications need to be rebuilt against the new version?

And the more general related question is, what are the differences in the metadata produced for a .NET Standard DLL compared to a .NET Framework one, and how/if do they affect the assembly resolver?

(to pre-empt the comment "why not just try it and see", I want to know if this is a supported scenario, not just whether technically it might work for me)

解决方案

.Net Standard is a compatible cross-section between (but not limited to) .Net Framework and .Net Core

Think of it like this

Or, one of the more standard propaganda pictures

There are lot of things in .Net Framework that just doesn't make a lot of sense in .Net Core. Windows specific things for instance.

However, what you can do is use The .NET Portability Analyzer to work out any glaring compatibility problems

Want to make your libraries multi-platform? Want to see how much work is required to make your application compatible with other .NET implementations and profiles, including .NET Core, .NET Standard, UWP, and Xamarin for iOS, Android, and Mac? The .NET Portability Analyzer is a tool that provides you with a detailed report on how flexible your program is across .NET implementations by analyzing assemblies. The Portability Analyzer is offered as a Visual Studio Extension and as a console app.

And here is another picture (of the tool), because it makes my post look detailed

To answer your question

If I simply open the source code for the library, change the target to .NET Standard 2.0 and rebuild it, can I just drop the new assembly in to replace the existing one and should the existing applications still work? Or would the applications need to be rebuilt against the new version?

Needs to be rebuilt as far as i know, try it see what happens and let us know.

There are so many things that could make this not work.

And the more general related question is, what are the differences in the metadata produced for a .NET Standard DLL compared to a .NET Framework one, and how/if do they affect the assembly resolver?

Not entirely sure what you mean, however it will resolve just the same when rebuilt.

(to pre-empt the comment "why not just try it and see", I want to know if this is a supported scenario, not just whether technically it might work for me)

Just replacing the assembly is not supported as far as i know or could research. However maybe someone else has more information here.

这篇关于.NET Standard DLL 二进制文件与 .NET Framework 二进制文件兼容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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