2

我尝试创建一个使用 Windows 窗体的 .NET 控制台应用程序,以创建和保存屏幕截图。创建新的控制台应用程序项目时,我尝试System.Windows.Forms使用 COM 引用通过依赖项导入库。

导入后,我在 Visual Studio 2019 中收到以下错误消息:

Severity Code Description Project File Line Suppression State Warning MSB3290 Failed to create the wrapper assembly for type library "{215d64d2-031c-33c7-96e3-61794cd1ee61}". Type library 'System_Windows_Forms' was exported from a CLR assembly and cannot be re-imported as a CLR assembly. screenshot_console C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 2705

依赖项窗口如下所示: VS 依赖项窗口

我尝试重新安装 VS 和 .NET 框架,但没有解决问题。

有什么方法可以成功导入库,还是无法将 Windows 窗体库导入控制台应用程序?

4

1 回答 1

1

抱歉回复晚了,这段时间忙于其他项目。

@Jimi是对的,我不小心创建了一个 .NET 核心项目,因此一些不存在的引用搞砸了整个项目。

之后,我能够毫无问题地添加 Windows.System.Forms 引用。

谢谢您的帮助。

于 2020-10-15T07:10:13.007 回答