Search Unity

Using System.Drawing.Image works but shows as error

Discussion in 'Editor & General Support' started by milosp, Apr 1, 2019.

  1. milosp

    milosp

    Joined:
    Dec 31, 2012
    Posts:
    23
    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?
     
  2. milosp

    milosp

    Joined:
    Dec 31, 2012
    Posts:
    23
    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.
     
    invisage and Nidhii like this.
  3. doasgloria

    doasgloria

    Joined:
    Nov 25, 2019
    Posts:
    2
    this is very useful !
    unity very stupid !
     
  4. Ducky-jr

    Ducky-jr

    Joined:
    Nov 2, 2015
    Posts:
    3
    Sorry to be extra stupid, I have the exact same issue but Im kinda confused how to solve it :|
     
  5. kaigangames

    kaigangames

    Joined:
    Nov 5, 2018
    Posts:
    1
    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.
     
    david_t7, MartinMa_ and femlol1femlol like this.
  6. david_t7

    david_t7

    Joined:
    Nov 29, 2022
    Posts:
    1
    thanks it was very helpful.
     
  7. Tej02

    Tej02

    Joined:
    Nov 2, 2021
    Posts:
    1
    copying the file from C:\Program Files\Unity\Hub\Editor\2020.1.6f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5 to where?