Using System.Drawing.Image works but shows as error

My code works but wherever I have System.Drawing.Image or System.Drawing.Bitmap the Visual Studio underlines it and shows as error:

The type or namespace name 'Image' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)

I have System.Drawing.dll in Assets\Plugins, and in VS I did Project>Add Reference>selected that dll (It is in the list of references in VS although with yellow exclamation mark with no additional info). I am using .NET 4.x scripting backend. Windows will be the only target and this dll is essential for the functionality of my app.

I would not care about seeing long error list but I cannot Attach to Unity, so debugging my project is hard. Is there a way to fix this?

Solved… 6 months with this issue and fixed 5 minutes after posting this.
That is the problem if I use that dll from unity…\mono\ directory, as every post around recommends.
Solution is using that dll from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 (4.6 also fails)
Unity will complain “Loading assembly failed: Assets/Plugins/x86_64/System.Drawing.dll” but VS does not.

2 Likes

this is very useful !
unity very stupid !

Sorry to be extra stupid, I have the exact same issue but Im kinda confused how to solve it :expressionless:

Copying System.Drawing.dll from

C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5

works for me. Doesn’t give any errors in Unity Editor as well.

3 Likes

thanks it was very helpful.

copying the file from C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5 to where?

i know its an old thread but i fixed this simply by going to Project Setting → Player scroll down to confuration and changed the Api Compatibility Level to .NET Framework. for some reason it was trying to use .NET Standard 2.1… hope it helps someone out there.

2 Likes