Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.
share|improve this answer
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. –  Jay Cummins Sep 10 '13 at 12:18

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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