无法解析.Net Core 3.1中的System.Windows.Forms.dll [英] Unable to resolve System.Windows.Forms.dll in .Net Core 3.1

查看:884
本文介绍了无法解析.Net Core 3.1中的System.Windows.Forms.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方案,我们在.Net core 3.1类库中使用旧版.Net Framework dll。在内部.Net Framework dll使用的是.Net核心无法解析的System.Windows.Forms.dll。

I have a scenario where we are using a legacy .Net Framework dll in .Net core 3.1 class library. Internally .Net Framework dll is using System.Windows.Forms.dll which .Net core is not able to resolve.

运行时出现以下错误消息

I am getting below error message during runtime

无法加载文件或程序集'System。 Windows.Forms,版本= 4.0.0.0,文化=中性,PublicKeyToken = b77a5c561934e089'。系统找不到指定的文件。

在理想情况下,将System.Windows.Forms.dll添加到类库没有意义,但是没有任何方法可以在.Net核心类库中添加System.Windows.Forms及其依赖项。

In a ideal world there is no point in adding System.Windows.Forms.dll to a class library but is there any way to add System.Windows.Forms and its dependencies in .Net core class library.

注意:我已经尝试过手动添加System.Windows.Forms.dll,但没有成功。

推荐答案

我得到了解决方案,我们可以通过框架参考来实现。

I got the resolution, we can achieve this by framework reference.

<FrameworkReference Include="Microsoft.WindowsDesktop.App" /> 

有关更多详细信息,请参考 https://natemcmaster.com/blog/2019/01/09/netcore-primitives-3/

For more details please refer https://natemcmaster.com/blog/2019/01/09/netcore-primitives-3/

这篇关于无法解析.Net Core 3.1中的System.Windows.Forms.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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