.NET Core 2.2 程序集 System.Windows.Forms 丢失 [英] .NET Core 2.2 Assembly System.Windows.Forms missing

查看:43
本文介绍了.NET Core 2.2 程序集 System.Windows.Forms 丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我在 .NET Framework 4.0 中的项目迁移到 .NET Core 2.2.但是我的程序执行出错了.

I want to migrate my project in .NET Framework 4.0 to .NET Core 2.2. But I have an error in my program execution.

我的项目想要使用 Assembly 类加载 .dll,它在 .NET Framework 4.0 上工作正常,但在 .NET Core 2.2 上不工作.它抛出了一个异常:

My project wants to load a .dll with the Assembly class, it's working fine with .NET Framework 4.0 but not with .NET Core 2.2. It's throwing a n exception:

System.Reflection.TargetInvocationException:调用的目标已抛出异常.---> System.IO.FileNotFoundException: 无法加载文件或程序集System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

using System.Reflection; // Assembly class

var pathToDll = "../../../../";
var asm = Assembly.LoadFrom(pathToDll);

var callingProgObject = asm.GetType("RandomType.CallingProg");
MethodInfo method = callingProgObject.GetMethod("MethodInDll");

var input = new InputForDll();
method.Invoke(callingProgObject, new object[] {input}); // <-------- error

我需要导入一个兼容 .NET Core 2.2 的包,类似于 .NET Framework 4.0 的 System.Windows.Forms?

I need to import one package compatible for .NET Core 2.2 similar to System.Windows.Forms of .NET Framework 4.0?

我的 NuGet 包安装在解决方案中:

My NuGet packages installed in Solution:

不重复 如何在.NET Core类库中使用System.Windows.Forms

推荐答案

没有适用于 .NET Core 的 Windows 窗体(或 WPF).

There is no Windows Forms (or WPF) for .NET Core.

你想要的是不可能的

(但在下一个主要版本中使用定义的 .NET Core 子集可能是可能的)

如果您列出您的要求,也许人们可以建议另一种方法来做到这一点,但它不会是 Windows 窗体.

If you list your requirements, maybe people can suggest another way to do it, but it won't be Windows Forms.

这篇关于.NET Core 2.2 程序集 System.Windows.Forms 丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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