I've inherited an asp.net website that is a mix of VB.Net webforms and C# MVC.
Recently, on deployment to the server, we get an error:
System.ArgumentException: An item with the same key has already been added. at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream) at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture) at System.Web.Compilation.BaseResXResourceProvider.GetObject(String resourceKey, CultureInfo culture)
This error persists until the application is reset (by tweaking the web.config).
The site uses resx files for translations and if we catch the exception it seems to come from the first use of a resource string.
I think this is a duplicate of Temporary files asp.net resx files, "item with the same key has already been added" but I don't have enough 'rep' to comment on that post.
My gut feel is that it's caused by a race condition to load the satellite assembly for the local resource file. My other idea is that it's a genuine duplicate due to us hosting the same code on 2 different IIS websites on the same server (one for 'staging' and the other is production). This is maybe causing it try load a duplicate shadow copy of the resource assembly from the temporary IIS files. To try prove this, I've deleted the temporary files and the error does go away but that could just be a result of it recompiling the application.
We don't get this error in development, only after a deployment to the server (using MSDeploy). I've tried deleting temporary IIS files on deploy but that hasn't made any difference.
Potentially a separate issue or a symptom of this but we also see CPU go to 100% on deployment and the worker process shows a number of requests that just seem to run forever. I wonder if this is showing that that the threads are deadlocked - maybe all waiting on loading the satellite resource assembly??
Anybody seen this behaviour before and can shed some light or some more avenues to explore?