我尝试创建一个使用 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 窗体库导入控制台应用程序?