Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type library 'System_Windows_Forms' was exported from a CLR assembly and cannot be re-imported as a CLR assembly

I tried to create a .NET console application that uses Windows Forms in order to create and save screenshots. When creating a new console application project, I try to import the System.Windows.Forms library via the dependencies using a COM refernce.

After the import, I get the following error message in 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

The dependencies window looks like this: VS dependencies window

I tried reinstalling VS and the .NET framework, but it did not resolve the issue.

Is there any way I can successfully import the library or is it not possible to import windows forms libaries to console applications?

like image 980
DaWoschbar Avatar asked Sep 03 '25 04:09

DaWoschbar


1 Answers

Sorry for the late response, got busy with some other projects in the meantime.

@Jimi was right, I accidentaly created a .NET core project, therefore some references where not there and messed up the whole project.

Afterwards I was able to add the Windows.System.Forms reference without any issues.

Thank you for your help.

like image 121
DaWoschbar Avatar answered Sep 04 '25 22:09

DaWoschbar