After converting a solution from Visual Studio 2008/.NET 3.5 to 2010/.NET 4.0, building it resulted in this error: “Unknown build error, ‘Item has already been added. Key in dictionary: ‘…’”. Howver, after a second build try (for example, using F5 or Ctrl+F5), the process completed successfully an the application started normally.
After many research hours, we’ve identified the issue: in our solution, within the project that initially failed to build, there were 2 Icon.ico files, one in the Properties folder, and one referred as a link from a different folder, but shown as a link in the same Properties special folder of the project. Visual Studio 2008 didn’t complain about it, but Visual Studio 2010 does.
We have resolved the issue by removing one of the Icon.ico files (the actual Properties/Icon.ico file), that wasn’t used as a resource in the project anyway (it was added there just because the link file didn’t work as an icon resource for the application due to a manifest error, but the file existed also in an Images folder where we could use it from; the link file was important because of some internal work).
I hope this would help someone, sometime, as this issue was very difficult to narrow down and resolve (the error message shown by Visual Studio 2010 wasn’t helpful at all).