Search Unity

System.Windows.Forms.dll assembly is referenced by user code warning - can't find src

Discussion in 'Scripting' started by Pirs01, Oct 20, 2013.

  1. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    Hello,

    I'm getting this warning message that I would like to get rid of:
    While it is true I tried
    Code (csharp):
    1. using System.Windows.Forms;
    it has been commented out since. Searching entire solution for "forms" in mono finds nothing relevant. I tried removing the "using" line instead of just commenting it out but it didn't help. Another possibility I considered was that it's referenced in a DLL. However I tried removing only DLL (uLink) from project and that didn't help either.
    In short I am out of ideas where this alleged reference resides.
     
  2. karljj1

    karljj1

    Joined:
    Feb 17, 2011
    Posts:
    440
    Is this partly of your unity project or a.net DLL you are building for unity? If it's a DLL then its probably in the project references.
     
  3. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    It's a Unity project

    EDIT:
    Is it possible that it's some kind of a build cache thingy? Is there a forced full rebuild option of some kind available?

    EDIT:
    As suggested here I deleted content of Unity\Editor\Temp, delted previous build, reimported all but non of that helped with the warning.


    EDIT:
    I only get the warning when doing build but not when running in editor.
     
    Last edited: Oct 20, 2013
  4. Aleph0

    Aleph0

    Joined:
    Feb 28, 2014
    Posts:
    7
    I'm having exactly the same problem... Did you find any solutions ?

    I'm not using System.Windows.Forms at all but the warnings are there even if I put all my code in commentary. They only show up after the build and I have no problem running my application in the unity editor.
     
  5. karljj1

    karljj1

    Joined:
    Feb 17, 2011
    Posts:
    440
    Try changing your build settings (Api compatibility level) so it uses .Net instead of .Net subset which it uses by default.
     
    Last edited: Mar 17, 2014
  6. Aleph0

    Aleph0

    Joined:
    Feb 28, 2014
    Posts:
    7
    I've already done that but it doesn't change anything.
     
  7. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Do you have any dll files in your project?
     
  8. Aleph0

    Aleph0

    Joined:
    Feb 28, 2014
    Posts:
    7
    Yes, I have all the EmguCV library dll files and System.Drawing.dll that I need for EmguCV in my project. I have also another warning that concerns OnMouse_events but I don't use that either...
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It seems those dlls are not compatible with Unity.
     
  10. Aleph0

    Aleph0

    Joined:
    Feb 28, 2014
    Posts:
    7
    Those dlls are working fine in the Unity editor and in PC/MAC/Linux Standalone but at the moment, my application doesn't work on Android, probably because of the warnings I have.
     
  11. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Yes, that's the point. It may work, but there is no full compatibility.
     
  12. Aleph0

    Aleph0

    Joined:
    Feb 28, 2014
    Posts:
    7
    Emgu.CV.UI.dll (and ZedGraph.dll) seems to be the dll that was provoking the OnMouse_events warning.

    But I think you were right for the System.Windows.Forms. It seems to be linked to the main dll of EmguCV.
     
    Last edited: Mar 21, 2014
  13. muzhiguinie

    muzhiguinie

    Joined:
    Nov 7, 2014
    Posts:
    3
    Has Anyone solved this problem? I got this problem too... And I've spent 1 whole day solving it, still not get resolved.
    My situation is:
    I was trying to use System.Windows.Forms.dll in my Unity project, but I got this problem when I build it and want my app run on my Android Phone. So I noticed that I can not use it. So I delete this dll in my Plugin folder and comment out the using import in my code. But I still got this error.

    Is there anyone know how to solve this ? In short I am really out of ideas
     
  14. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    In short: System.Windows.Forms.dll is not completely compatible with Unity and that's why it doesn't work on all platforms.
     
  15. muzhiguinie

    muzhiguinie

    Joined:
    Nov 7, 2014
    Posts:
    3
    Hi Dantus, thank you very much for you reply. I've found the reason is caused by my Android SDK version incompatible.
    I've changed to another Android SDK. and now I can build and run perfectly on my Android Phone.
    Hope this could help anyone who may encounter this problem too.
     
  16. miker88

    miker88

    Joined:
    Jan 8, 2013
    Posts:
    1
    may i know what android sdk version is that?
     
  17. swastiksoni

    swastiksoni

    Joined:
    Dec 23, 2013
    Posts:
    9

    Hey can you please tell me the android sdk version you have used ?
     
  18. TharosTheDragon

    TharosTheDragon

    Joined:
    Sep 2, 2017
    Posts:
    13
    We know it doesn't work on all platforms, but why is Unity saying it doesn't work on the StandaloneWindows platform? It should work, and it does given the right import settings.
     
  19. Straafe

    Straafe

    Joined:
    Oct 15, 2012
    Posts:
    73
    Having the same issue when trying to build to WebGL only (PC works fine, and Android too I believe), no idea where Windows.Forms was used in code, I never added it anywhere myself in code (so it must be in a DLL from some asset I'm using or something) and am having trouble tracking it down. I wish the warning gave a clue to where it was.
     
    Last edited: Nov 28, 2017
    Flem100 likes this.
  20. eljavivi290296

    eljavivi290296

    Joined:
    Jun 14, 2018
    Posts:
    1
    Hi guys,

    I am new with Unity and I have a problem with this topic.
    Last week I built and run an App for Augmented Reality with Unity + Vuforia without any problems and it works fine with the mobile device.
    But this week I've tried to build and run a new App version with some design changes and this message appears when compiling.

    "System.Windows.Forms.dll assembly is referenced by user code, but is not supported on Android platform. Various failures might follow.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)"

    Unity builds the App but when I try to run it with the mobile device the camera doesn't works. It shows a blue-brown background.
    I've searched into forums and I am not able to find the solution.

    upload_2018-7-19_13-22-44.png

    Could you help me please?
    Thanks in advance!
     
    Flem100 likes this.
  21. lawura

    lawura

    Joined:
    May 22, 2019
    Posts:
    3
    File>BuildSettings>Android>PlayerSettings>Inspector>OtherSettings>Configuration>ApiCompatibilityLevel:
    change .NET 4.x or whatever else you are using to .NetStandard 2.0
     
    GabrielC15, devDonut and mikeeyfu like this.
  22. mikeeyfu

    mikeeyfu

    Joined:
    Mar 31, 2017
    Posts:
    1
    it works, thank you very much!
     
    unity_U2liQfgwkUxymw likes this.
  23. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,087
    Also having this issue but no idea what uses that .dll. Unity should add to the warning what "user code" namespace/assembly/class uses incompatible dll.
     
    revu_, Bshsf_9527 and Flem100 like this.
  24. boysenberry

    boysenberry

    Joined:
    Jul 28, 2014
    Posts:
    365
    Does this mean with .Net 4.x selected we're going to get this warning?

    I am only interested in developing for the Windows Desktop environment. Should I even get this warning?
    "System.Windows.Forms.dll assembly is referenced by user code, but is not supported on StandaloneWindows64 platform. Various failures might follow."

    I have the TestRunner setup and one script that uses reflection:

    var type = (from assembly in AppDomain.CurrentDomain.GetAssemblies()
    from type2 in assembly.GetTypes()
    where type2.Name == className && type2.GetMethods().Any(m => m.Name == methodName)
    select type2).FirstOrDefault();

    That is it (outside of having it setup to use .Net 4.X).

    Is this warning okay to ignore then?
     
    drew55 likes this.
  25. drew55

    drew55

    Joined:
    Dec 13, 2017
    Posts:
    44
    Hi team,

    Ditto @boysenberry -- this issue remains an open mystery (using 2020.1.13).

    I've done a file/byte search for "Windows.Forms" and there are hits in the player cache only on OSX and on iOS. This seems to suggest that `System.Windows.Forms` is getting pulled in by Unity. (See attached screen shot)

    Please advise.
     

    Attached Files:

    jdtec, sarynth and boysenberry like this.
  26. sarynth

    sarynth

    Joined:
    May 16, 2017
    Posts:
    98
    Ran a build today and noticed this error.

    Checked my scripts, and I don't have any using System.Windows.Forms in any of my *.cs files.
     
  27. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,269
    Same issue in 2020 - can't say it is .net 4.5 specific, though do have to use it for an asset.
    It would help if the warning actually gave some detail on 'where' it found the issue.
     
    boysenberry likes this.
  28. stamatian

    stamatian

    Joined:
    Jul 13, 2018
    Posts:
    36
    I'm using Unity 2020.21f1 and I have the same message after I build and run for Android:

    Code (CSharp):
    1. System.Windows.Forms.dll assembly is referenced by user code, but is not supported on Android platform. Various failures might follow.
    2. UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()
    It's popping only when I use .NET 4.x... When I use .NET Standard 2.0 is not showing up...
     
  29. EmpirisoftNathan

    EmpirisoftNathan

    Joined:
    Sep 6, 2016
    Posts:
    12
    Confirmed, this warning does not manifest when targeting .Net Standard.

    Generally speaking, if .Net Standard target meets your needs (ie the feature set of the framework) its preferable anyway, as your code will be much more portable. I recently ported my assemblies to Standard and it wasn't a huge deal in my case.
     
  30. Fred_Flintstones

    Fred_Flintstones

    Joined:
    Oct 27, 2015
    Posts:
    3
    For me it was the package "version control" aka collaborate - removed that package and it went away
     
    Suzie-QQ and Bshsf_9527 like this.
  31. stamatian

    stamatian

    Joined:
    Jul 13, 2018
    Posts:
    36
    I removed Version Control package and now the warning disappeared!
     
    Suzie-QQ likes this.
  32. homemacai

    homemacai

    Joined:
    Jul 22, 2020
    Posts:
    74
    Did this and also got rid of the error! Thanks!
     
  33. wildenberg84

    wildenberg84

    Joined:
    May 1, 2019
    Posts:
    1
    Can confirm that assembly is referenced somewhere in version control. Warning also pops up in an otherwise empty project, removing version control removes warning.
     
  34. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,408
    removed Version Control package - but still happening (2020.3.14f1)

    from file search can see these ones, so maybe its those (2D Sprite Shape and Vector graphics)
    upload_2021-9-25_11-50-45.png
     
  35. Bshsf_9527

    Bshsf_9527

    Joined:
    Sep 6, 2017
    Posts:
    43
    i like you
     
  36. GlenZPS

    GlenZPS

    Joined:
    Sep 12, 2019
    Posts:
    25
    removed Version Control package - but still happening (2020.3.36f1c1)
    UnityHelpReport.png
     
  37. MaxQuinonesSantander

    MaxQuinonesSantander

    Joined:
    Feb 20, 2020
    Posts:
    11
    I did that and the error went away, but my windows build still not working.