5

I have a shared DLL that use across multiple ArcMap AddIns. It rarely changes, but recently I've had to modify it and I started getting MissingMethodExceptions whenever I made calls to classes in that shared DLL.

After some investigation, I realized that there are other ArcMap AddIns that carried an older version of the shared DLL that were being loaded first. And if I clear out all of the other AddIns and blow away the assembly cache, I run by AddIn with new Shared DLL with no issues.

Is there a specific order of AddIn loading from the assembly cache? In my case, it appears to be oldest first. Is there a way to alter the order of loading?

Related Links:
http://forums.arcgis.com/threads/29870-Add-ins-that-share-same-custom-library

2 Answers 2

3

Three options I see are:

  1. Strongly name all your assemblies so that they are uniquely identified and only the correct one is loaded/referenced. This is mentioned as the solution in the thread you linked.
  2. Use ILMerge to merge the shared assembly into the main assembly, greatly simplifying deployment, version management, etc. You also can make this part of your build process.
  3. An option mentioned on the ILMerge page above (and promoted as being a better solution) is embedding the secondary assemblies as resources in the main assembly. This is only discussed in the context of embedding assemblies in an executable, but I think it should work for embedding assemblies in a class library as well. Never tried it though.
1
  • 1
    I tried #3. I had to strongly name the shared assembly in order for it to work, which makes sense if you have multiple AddIns that can possibly raise the AssemblyResolve event. If the assembly isn't strongly named, then I'm back where I started. Commented Sep 10, 2013 at 12:18
1

Expanding on the @blah238's ILMerge option:

I was able to run ilmerge and combine my shared assembly with my AddIn assembly. I had to specify the path to the ESRI.ArcGIS.Desktop.AddIns and the target platform.

ilmerge.exe /lib:"C:\Program Files (x86)\ArcGIS\Desktop10.1\bin" /targetplatform:v2 /out:C:\XXXX\bin\Debug\XXXXCombined.dll C:\XXXX\bin\Debug\XXXXX1.dll C:\XXXX\bin\Debug\XXXXX2.dll

I was able to manually replace the AddIn DLL + Shared DLL in the esriAddIn file with the single combined DLL from ILMerge. Works like a charm! I haven't worked out the build process yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.