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 project which implements BaseTool and BaseToolbar. For those of you who don't know already, the name of the dll containing these base classes has changed from ESRI.ArcGIS.ADF to ESRI.ArcGIS.ADF.Local between ArcGIS 9.x and ArcGIS 10.x. However, the namespaces I need have remained the same.

To deploy this toolbar, I have been switching back and forth between dev machines running ArcGIS 9.x and 10.x, updating the reference, and then recompiling. I don't have to change a single line of code. Although this is a fairly easy process, I then have to create and manage separate installers for 9.x and 10.x versions.

I've been banging my head against the wall trying to come up with a more elegant solution. Something along the lines of changing the reference at install time? Does anyone have any suggestions?

share|improve this question
    
Migrate to a non-ESRI solution? :-) –  whuber Mar 25 '11 at 15:06

1 Answer 1

up vote 2 down vote accepted

The way .NET runtime assembly resolution works, there is no way to specify redirecting to an assembly of a different name.

The problem is actually at a lower level of the .NET type system than the assembly name itself. Although it may seem that e.g. the BaseTool types are the same and only their placement (assembly) differs, that is not the case. A .NET type reference in its complete form consists not only of the full type name, but also contains the assembly name, including the public token (if any). So the BaseTool class in ESRI.ArcGIS.ADF is essentially a completely different type than BaseTool in ESRI.ArcGIS.ADF.Local. From the .NET viewpoint, there is no connection between them whatsoever, they are not interchangeable.

It is not exactly true that you are not changing anything in your code. Visual Studio will change your .csproj file to point to the particular assembly when you switch references. The reference then gets compiled in your assembly. Now, there are ways to fiddle with the assembly reference table inside an already compiled DLL, but that's a hack which brings more trouble than it's worth.

.NET has facilities for dealing with changes in type placement called type forwarding which is done via the TypeForwardedToAttribute, but it requires changes to the original assembly. The original assembly also needs to be present on the system alongside the new assembly, so this could not have been done in the case of ESRI.ArcGIS.ADF.

The assembly renaming is a breaking change and as such, any code dependent code will by definition break and needs to be updated accordingly. That being said, you will need two separate installers.

share|improve this answer
    
Thanks for the thorough response. –  user890 Mar 25 '11 at 16:25

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.