Can't use System.Drawing in C# console application

44 views Asked by At

I'm trying to make a program that would create images in C#. It would make some calculations, without any user interface, then export a bitmap image. For that last part I tried to use System.Drawing as it seemed to be the easiest. But I just can't.

I'm using Visual Studio, I created a C# console project, and the framework is .NET (5, 6, 7, when I change it the problem stays the same). Under the project name, there is no "reference" tree, only "dependencies" where I can add either a COM reference, a project reference or a shared project reference (note that I'm translating the interface... there can be some mistakes). There is no "assembly" section in the reference manager.

I can add a COM reference to System.Drawing (either v2.0 or v2.4), but I get a warning MSB3290 "Failed to create the wrapper assembly for type library... Type library 'System_Drawing' was exported from a CLR assembly and cannot be re-imported as a CLR assembly.".

I would like to know what I'm doing wrong, and what could be the solutions or alternatives...

I tried to change the framework version, but honestly I'm already out of imagination. I looked for that problem on the internet, the answer were:

  • don't use .NET core (I am not)
  • re-install NuGet packages (I'm not using any)
  • add a reference to System.Form (same problem with that reference)
0

There are 0 answers