Search Unity

Build Failed: Where did these systems even come from?

Discussion in 'Scripting' started by Marscaleb, Jul 2, 2020.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,037
    I was trying to create a standalone build today, but it failed because of compiling errors that never showed up in all my testing.
    What really confuses me about this though, is that what produced these errors are things I never added, and quite frankly, I'm really confused as to why these are even there.

    I got three errors from three different scripts for having items in that "using" section at the very top of the script. I never touched these, except in a few occasions like when I needed a script to work with the scene manager. I don't even recall what these things were called. So why in the hell do I have whole sections in them that I never added, never seen in any other scripts, and to top it all off, cause compile errors because they don't actually exist? Where did these come from?

    All three give the error "the type or namespace name (word) does not exist". The lines are "using System.Net.Configuration" "using UnityEditor.Build.Pipeline" and "using System.Security.Policy"

    Now it is easy enough to just remove those lines so I can get it to compile my build, but seriously, how did these ever show up in the first place? Why am I getting random code added to my scripts that I never put there?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    It might help to mention which script(s) you're referring to. Are they scripts you wrote? Are they part of a package from Unity? Should be pretty trivial though to determine exactly when these lines of code were added using your source control system.
     
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,914
    In order to refer to a class in your script, you need a "using" statement at the top of your file so the compiler knows which namespaces to search in to find that class.

    When you type in a class name that isn't in either the default namespace or one of the "using" namespaces at the top of your file, many code editors like Visual Studio will often take the initiative and automatically add their best guess at which namespace you want based on the class name you typed. Sometimes they guess correctly, sometimes they don't. If you made a typo and later corrected it, you may not realize that Visual studio has thrown in a using statement at the top of your file that sticks around even after you fix your error.