Thursday, July 12, 2007
Posted on Thursday, July 12, 2007 10:20:28 AM (Mountain Daylight Time, UTC-06:00)  Comments [2] | 
Categories: .NET | ArcMap
This was pretty weird, and thankfully others on my team had already run into it, so it was a quick fix. Thought I'd share it...

Here's the basic scenario:

We have some base classes which contain a lot of common code for feature and object class extensions. The ObjectClassExtensionBase class implements IClassExtension



This is a very simple Interface - it has two methods Init and Shutdown. All is well, and we've been building this project for a couple of months. This morning I created a new project, in which I referenced the assembly containing the base classes.

 

Suddenly I start getting 2 compile errors in the "Base" class assembly:



How's this for wack - the first error says that I need to implement Sub Init for IClassExtension, and the second error says that my Sub Init can not implement IClassExtension.Init because it's not present in IClassExtension??! They contradict each other!

After some head scratching I asked around, and others have run into this recently. Seems that the issue is related to some referenced ESRI .NET assemblies being located in the GAC. What's even more bizzare is that the error can crop up in a different assembly than the one that has the offending reference.

In my situation, our "BaseClass" assembly had not changed. Yet that's where the compile error showed up. I checked all the ESRI references in that assembly, and they were all pointing to the expected "C:\Program Files\ArcGIS\DotNet\something.dll".

However, when I looked at the references in my "new" project, the ESRI.ArcGIS.System assembly it was referening was located in the GAC...



Conveniently I did not actually need this reference, and as soon as I dropped it, everything compiled just fine.

Interestingly - if I add this reference via the standard Visual Studio "Add Reference..." dialog, it uses a copy that's in "C:\Program Files\ArcGIS\DotNet"



But, if I add it via the ESRI ArcGIS Reference add-in, it adds a copy from the GAC and the error returns.



As for why this is an issue, I'm guessing it's an all or nothing type of thing - either all the ESRI references should come from the GAC, or all from C:\Program Files\ArcGIS\DotNet, and a mix will cause problems.

Anyhow - hope this is useful to someone else.
Thursday, July 12, 2007 5:48:36 PM (Mountain Daylight Time, UTC-06:00)
Interesting, Dave. I just checked in a current project of mine and indeed too have a mix, some references point to the GAC and others to \ArcGIS\DotNet. The project is building error free, though.

I'm not sure at what point some of the Path values to the referenced assemblies switch to the GAC. I created a new project via File > New Project > Visual Basic > ArcGIS > Desktop > Class Library (ArcMap), then in the References panel in the subsequent wizard (ArcGIS Project Wizard > Add Reference) any reference added points to my \ArcGIS\DotNet folder. In contrast to your experience, if I add a reference via References > Add ArcGIS Reference after project creation, it too points to \ArcGIS\DotNet folder.

I tried saving > closing > reopening the project a few times to see if any of the ref pointers would change to the GAC, but no go, so I'm at loss as to what triggers the switch.


Ron
Ron Bruder
Thursday, August 02, 2007 11:08:50 AM (Mountain Daylight Time, UTC-06:00)
This showed up in Visual Studio for us after installing ArcGIS Desktop Service Pack 3. It looks like the service pack doesn't remove the GAC references to the old versions (9.2.0.1324) before installing the new versions (9.2.3.1380). In our case we had to edit VB project files to update the version numbers and clean up the GAC to compile old projects against SP 3.
Comments are closed.