ArcGIS 10.1 stand alone .Net application working with 10.2

2708
10
Jump to solution
03-14-2014 11:17 AM
ScottLangstaff
New Contributor
I have a standalone .Net application that references the arc com objects. The program was compiled with VS 2010 on a pc that has ArcGIS 10.1 installed on it.

I tried running the same software on a pc with ArcGIS 10.2 running on it and the software fails to run.

I was hoping not to have two separate builds of the software, dependent on the version of ArcGIS installed.

Is there a way I can compile the software so that it works with both versions of ArcGIS 10.1 and 10.2?
0 Kudos
1 Solution

Accepted Solutions
RichardWatson
Frequent Contributor
The problem is that when you link your application with ESRI assemblies the resulting executable will reference the exact version that you linked against.  Setting the assembly reference to be non-version specific only changes what it does when it builds.  This is how .NET behaves and has nothing to do with ESRI.

The way that you can make this work is to redirect your assembly references:

http://msdn.microsoft.com/en-us/library/7wd6ex19%28v=VS.100%29.aspx

You can see how ESRI does this by looking at ArcMap.exe.config.  You could build against 10.1 and then (assuming ESRI made no breaking API changes) provide an application configuration for your 10.2 delivery which simply redirected your 10.1 assembly references to 10.2.  I have done this very thing.

View solution in original post

0 Kudos
10 Replies
DuncanHornby
MVP Notable Contributor
I'm guessing your standalone is attempting to reference the old 10.1 location?

Just an idea, not sure if it is correct as I have not had to build a stand alone application for some time but in VS, in the solution Explorer panel> References

set each ESRI reference to Copy Local = TRUE. This should bundle up the DLLs into the same folder as your executable.

Duncan
0 Kudos
BBulla
by
Occasional Contributor
Are you sure it isn't the OS that is the problem?  In my office we have some people on XP 32 bit and others on Win7 64 bit, which causes me all sorts of problems when distributing ArcGIS tools.
0 Kudos
ScottLangstaff
New Contributor
I don't think its an operating system problem. The two desktops are identical Win 7 virtual machines.
0 Kudos
ScottLangstaff
New Contributor
I'm guessing your standalone is attempting to reference the old 10.1 location?

Just an idea, not sure if it is correct as I have not had to build a stand alone application for some time but in VS, in the solution Explorer panel> References

set each ESRI reference to Copy Local = TRUE. This should bundle up the DLLs into the same folder as your executable.

Duncan


I was hoping that the same executable would be able to work with both versions of ArcGIS's objects. I know it was that way back in ArcGIS v9.* but when they moved to 10, it seems like I need a different executable for each ArcGIS version. I do understand that there were allot of changes between ArcGIS 9 and 10, so it makes sense that I need a different executable, but I had hoped that within 10.1 and 10.2, there would not be as many changes.
0 Kudos
RichardWatson
Frequent Contributor
The problem is that when you link your application with ESRI assemblies the resulting executable will reference the exact version that you linked against.  Setting the assembly reference to be non-version specific only changes what it does when it builds.  This is how .NET behaves and has nothing to do with ESRI.

The way that you can make this work is to redirect your assembly references:

http://msdn.microsoft.com/en-us/library/7wd6ex19%28v=VS.100%29.aspx

You can see how ESRI does this by looking at ArcMap.exe.config.  You could build against 10.1 and then (assuming ESRI made no breaking API changes) provide an application configuration for your 10.2 delivery which simply redirected your 10.1 assembly references to 10.2.  I have done this very thing.
0 Kudos
ScottLangstaff
New Contributor
The problem is that when you link your application with ESRI assemblies the resulting executable will reference the exact version that you linked against.  Setting the assembly reference to be non-version specific only changes what it does when it builds.  This is how .NET behaves and has nothing to do with ESRI.

The way that you can make this work is to redirect your assembly references:

http://msdn.microsoft.com/en-us/library/7wd6ex19%28v=VS.100%29.aspx

You can see how ESRI does this by looking at ArcMap.exe.config.  You could build against 10.1 and then (assuming ESRI made no breaking API changes) provide an application configuration for your 10.2 delivery which simply redirected your 10.1 assembly references to 10.2.  I have done this very thing.


Thanks rlwatson, This has solved my problem. Doing some more digging, it appears that in the ArcGIS v9 ESRI provided a automatic redirection. I guess this did not continue in v10.* .

http://resources.esri.com/help/9.3/arcgisengine/dotnet/1b2bbc48-1c2c-4096-9970-6cb4abf2a4d7.htm
0 Kudos
DuncanHornby
MVP Notable Contributor
Richard,

This exe.config file, how did you create it for your project? Did you copy the ArcMap.exe.config and then edit it, or is it something you create from within the Visual Studio project?

Duncan
0 Kudos
ScottLangstaff
New Contributor
I already had a program.exe.config file for my program. I just copied the <runtime> section from the ArcMAP.exe.config into my program.exe.config.

I would also be curious if this can be configured in Visual Studio
0 Kudos
RichardWatson
Frequent Contributor
In Visual Studio, I added an "Application Configuration File" project item and then edited it.  I used the information in ArcMap.exe.config as a guide and changed the content to values that made sense for what I was trying to do.
0 Kudos