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

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

问题描述

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

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,Culture=neutral,PublicKeyToken=b77a5c561934e089".系统找不到指定的文件.

在理想的世界中,将 System.Windows.Forms.dll 添加到类库是没有意义的,但是有什么方法可以将 System.Windows.Forms 及其依赖项添加到 .Net 核心类库中.

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/博客/2019/01/09/netcore-primitives-3/

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

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