- Home /
DEBUG;TRACE; Compile Problems
I have a simple project with a couple of relatively simple scripts. I am getting this error when I try to compile:
An item with the same key has already been added. (Error: System.ArgumentException) (Assembly-UnityScript)
Now, if I remove this line from both of the project Assembely-CSharp->Options->Compiler->Define Symbols and Assembely-UnityScript->Options-Compiler->Define Symbols:
DEBUG;TRACE;
It will compile, however, every single time I add a new script, it is back, and it's becoming quite a nuisance.
I've tried deleting everything but the assets and config folder, and this problem persist. It doesn't look like I am the only one either, as there are a couple of threads going on about this:
http://answers.unity3d.com/questions/989322/javascript-error-error-error-systemargumentexcepti.html
I am using 5.1 as well. Is there a solution for this?
Some more context:
What platform you build for?
What system you're working on?
Does that error come with a stacktrace and / or more details?
Have you checked the compiler directives in the project settings in Unity itself?
Does this happen even when you try to test your project in the editor or only when you try to build your project?
Since this seems to be a rare case, do you use any external libraries / uncommon namespaces / ...?
Can you actually start a new project and reproduce this error with some simple steps? If not, try to duplicate your project and start removing stuff to see when it's working again.
You said you removed those compiler symbols. Do you mean inside of $$anonymous$$onoDevelop / VisualStudio?
Answer by meekrob · Sep 23, 2015 at 07:22 AM
I know this post is several months old, but it just started happening for me too after installing the Unity Test tools. My fix is similar but also temporary. I remove the duplicate DEBUG and TRACE terms inside of the Assembly-UnityScript.unitproj XML file. The duplicate terms are inside the <DefineConstants> element.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_5_1_1;UNITY_5_1;UNITY_5;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_LICENSE;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_EDITOR_METRICS;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_LOCALIZATION;UNITY_ANDROID;UNITY_ANDROID_API;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_EGL;ENABLE_NETWORK;ENABLE_RUNTIME_GI;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_MONO;DEVELOPMENT_BUILD;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;
UNITY_EDITOR_OSX</DefineConstants>
...
</PropertyGroup>
After removing them, the compile error is resolved, but there are roughly 70+ warnings coming from the new package that only show up ONCE!
Then things are fine (no more warnings from the package) for the rest of the session.
I wish I had a better idea of the build process for C#, so that I might track this down. Alternatively, ONE of these packages (or ALL packages in general) should check the DEFINEs before they add to them.
Your answer
Follow this Question
Related Questions
Unhandled Exception: Mono.CSharp.InternalErrorException: Internal error 1 Answer
Unity wont launch 1 Answer
Compilation failed because the compiler couldn't be executed 1 Answer
How to fix Unity compiler error when building WP8.1 game? 2 Answers
Does Mono evaluate equality of objects differently then MS .NET 1 Answer