Select to view content in your preferred language

ArcObjects Extension and COM Interop Problem

484
1
05-11-2012 03:16 PM
PhilipBailey1
Emerging Contributor
I have developed two extensions for ArcGIS ArcMap 10 using VB.net in Visual Studio. Both extensions use another DLL that I have developed call gis.dll that contains some basic ArcObjects utility functions. I am getting problems when both extensions are deployed to the same computer. The extensions seem to get confused when different versions of the gis.dll are deployed with each extension. They end up referencing the wrong copy of the gis.dll. i.e. My extensions are released to users at different times. The version of the gis.dll included with each extension may be different. I am getting errors when one of the extensions attempts to access the wrong copy of the gis.dll.

I am deploying my extensions using an MSI install pack, developed using Visual Studio. Do I need to register the gis.dll for COM Interop? I currently have this option disabled and suspect that the extensions are not referencing the copy of the gis.dll deployed to same folder as the DLL.

Thanks
0 Kudos
1 Reply
NeilClemmons
Honored Contributor
The ideal way to do this would be to install your gis.dll separately and register it in the GAC.  However, this would require that each new version of your dll be installed with policy files to point applications using an older version to the newer version.  This isn't hard to do, it just requires more work.  You can also install the gis.dll file with each extension and put it in the same directory as your extension's assemblies.  If you go this route then you have to make sure that you change the version number on the gis.dll file each and every time you make a change and recompile.  If you don't then your extensions will use whichever file is loaded first.  When the first extension loads, the .NET runtime loads any dependencies that it needs, which will include your gis.dll.  When your other extension loads, the gis.dll that sits alongside the extension assembly will NOT be loaded because it has the same version number as the file previously loaded.  The .NET runtime can't tell that the gis.dll is different from the one already loaded because it is only looking at the version number.  This is why it is important to change the version numbers.  Since you're extensions are not using the correct gis.dll, I'm guessing you didn't increment the version number when you made changes to the dll.
0 Kudos