- Home /
Monodevelop error after Unity 5.1 upgrade: An item with the same key has already been added.
I've just upgraded my project to Unity 5.1, and now monodevelop fails to build the project with the following error:
An item with the same key has already been added. (Error: System.ArgumentException) (Assembly-UnityScript)
I have lots of plugins (Standard Assets, iOSNative, ImageEffects among others), and can see no way of finding out where the problem is.
Anyone know how to narrow down where the problem might lie?
I've found that removing the iOSNative plugin files fixes the issue. However, this has the side effect of removing the Assembly-UnityScript project from the solution, so I am unsure if the fault is due to the Assembly-UnityScript being present, or something within the iOSNative plugin.
Also having this issue in 5.1. If I remove Assembly-UnityScript it goes away, but this is regenerated every time.
I have the same issue in Unity 5.1.0, but it's working O$$anonymous$$ on Unity 5.0.3. I'm not sure how fix the issue, but removing the Assembly-UnityScript or changing to release is not a solution for me. So I'll be using Unity 5.0.3.
Answer by steveg2357 · Jun 16, 2015 at 03:38 PM
It looks like the error may be caused by DEBUG and TRACE occurring twice in the DefineConstants section of the Unity project files (i.e., .csproj and .unityproj files).
Hello. You're right ! I edited this (click right on Assembly-UnityScript on the left tree, then Options, then Compiler and delete the first DEBUG;TRACE) and now it compiles correctly ! Thanks !
Thanks :) this worked for me and is a really quick solution! :)
I had the same problem but the error message was "An element with the same key already exists in the dictionary". The solution was the same, delete the superfluous DEBUG and TRACE options.
Having the same error. Since you seem to have found how to fix it, can you post instructions on how to do so? Sort of new to Unity.
Hi, this has been haunting me for quite a while. This solution worked for me as well, thanks!
Answer by jantje · Jun 15, 2015 at 09:56 PM
I filed a bug (703149) on this. Unfortunately, it's even simpler (although I found it with my 5.0.2 project when I opened it in 5.1). I made a new project in 5.1, and added a UnityScript .js file. Compiles fine in the Editor, but if you try to compile it in MonoDevelop (I'm on a Mac), you get the error. My personal theory is that the duplicate item(s) in question are the DEBUG and TRACE defines, as looking at the Application Output: Errors (click "Errors" at bottom right of MonoDevelop window), you see that they are in there twice, whereas if you compile in 5.0.x they are only there once. The 5.1 release notes mention those as having been touched in 5.1. But my guess could be incorrect.
While I can still debug with MonoDevelop, building in MonoDevelop gives that error and then won't try to compile the rest.
Great, thanks. Hopefully they will fix it in a co$$anonymous$$g update.
Yup. You can fix it manually for now Click right on Assembly-UnityScript on the left tree, then Options, then Compiler and delete the first DEBUG;TRACE
Awesome! Thanks for the tip! I had to do it for both Assembly-UnityScript AND Assempy-UnityScript-firstpass, but it worked!
Hello, 5.1, I can use you now :).
Answer by $$anonymous$$ · Feb 23, 2016 at 02:39 PM
Had the same error. Just changed the build type from debug to release. It worked.
This worked for me! In iOS Build Settings, change from release to debug, press "Build" and cancel the build. Change back to "Release" and all works fine.
Answer by crohr · Jun 09, 2015 at 08:00 PM
I have had this issue in the past and simply had to remove an extra assembly reference in Mono. I unfortunately do not recall the name, but it is typically the last assembly reference in the solution. Sorry I am not able to remember to name.
It is likely the Assembly-UnityScript, but I am uncertain. But I do know removing that Assembly reference doesn't harm anything.
Answer by Steredice · Jun 13, 2015 at 07:08 PM
I had the same error. I tried changing the references, deleting some, etc. It didn't work. I just changed the build from debug to release. And no more error.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200812im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Error trying to open script with Monodevelop 3 Answers
Ending my game 3 Answers
Really need help for my code! 2 Answers
MonoDevelop TODO task won't clear. 2 Answers
Monodevelop Fatal Error 0 Answers