在.NET Core 2.0中引用.NET Framework 4 dll [英] referencing .NET framework 4 dll in .NET core 2.0

查看:499
本文介绍了在.NET Core 2.0中引用.NET Framework 4 dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些用 .Net 框架 4.0 编写的dll,当我无法运行程序时,我将其引用为使用 .NET core 2.0 编写的项目。

I have some dll that is written in .Net framework 4.0 and I can't run my program when I'm referencing it to my project which is written in .NET core 2.0.

尽管我的IDE(vs 2017)可以在运行时Im正确识别从该dll导入的对象,但有以下异常:

Although my IDE (vs 2017) can recognize the objects imported from that dll correctly in run time Im having the following exception:

System.BadImageFormatException: 'Could not load file or assembly 'A_dotnet_4.0_A, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0ad20d08c672086a'. An attempt was made to load a program with an incorrect format.'

我试图:


  1. 将我的设置更改为任何CPU,就像我在帖子此处

  2. 试图清理重建我的项目。

有可能吗?如果可以,我应该怎么做。
在下面的链接中,似乎有可能-我可以

Is it even possible? and if it does, how should I do so. In the following link is seem like it is possible - I just can't understand how.

推荐答案

总结:

它不会无法工作,因为该DLL的.NET Framework版本太低。 .NET Core 2.0及更高版本支持引用其他.NET Standard dll(因此,.NET Core或.NET Framework或将来可能实现.NET Standard的任何其他库)。

It doesn't work because the .NET Framework version of that DLL is too low. .NET Core 2.0 and up support referencing other .NET Standard dlls (so either .NET Core or .NET Framework, or whichever other future library might implement .NET Standard).

.NET Framework 4.0不实现.NET Standard,因此它不产生.NET Standard兼容的dll:.NET Framework仅从版本4.5和更高版本开始实现.NET Standard。起来因此,如果可以找到为.NET Framework 4.5编译的该DLL的版本,则从理论上讲应该可以使用,除非有一些极端情况。

.NET Framework 4.0 does not implement .NET Standard, so it does not produce .NET Standard compatible dlls: .NET Framework only started implementing .NET Standard from version 4.5 and up. So if you can find a version of that DLL compiled for .NET Framework 4.5, it should theoretically work, barring some edge cases.

这篇关于在.NET Core 2.0中引用.NET Framework 4 dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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