Weird ArcObjects / Visual Studio Error – No Matching Sub on Interface…

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

Media_httpblogdavebou_qgcfr

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.

 
Media_httpblogdavebou_xribs

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

Media_httpblogdavebou_ujfkq

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 FilesArcGISDotNetsomething.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…

Media_httpblogdavebou_efidi

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 FilesArcGISDotNet”

Media_httpblogdavebou_gpiay

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

Media_httpblogdavebou_sgbhi

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 FilesArcGISDotNet, and a mix will cause problems.

Anyhow – hope this is useful to someone else.

Advertisement
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s