Select to view content in your preferred language

Pro 3.1 Forward Compatible with 3.3

772
2
05-14-2024 07:03 AM
StephenDavis1
Emerging Contributor

Hi,

We have a standalone (corehost) app written/compiled with Pro 3.1. We tried to run it on a machine with 3.3 installed and it didn't work. The documentation talks about the SDK being forward compatible between minor versions. Is that for the entire SDK or just the add-ins subsection of it? Is what we experienced with our stand alone app expected?

Thanks

2 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

@StephenDavis1 

Pro SDK documentation only mentions that ‘Add-ins’ are forward compatible between minor versions.  If you write a CoreHost standalone app for ArcGIS Pro 3.1 you can achieve forward compatibility as well, but there are a few caveats:

  1. Your CoreHost app is in essence a .NET console app with references to the following ArcGIS Pro assemblies: ArcGIS.Core and ArcGIS.CoreHost.  You have to make sure that the “Copy Local” attribute for these references is set to “NO”.   You also have to add code in your CoreHost app to resolve the path to these assemblies (they are located in the ArcGIS Pro installation bin folder).  This ensures that your CoreHost application is actually running the assemblies that are installed with ArcGIS Pro and not a potentially outdated (or mismatched versions) assembly copy included with your CoreHost app.
  2. Also, your CoreHost app cannot be a ‘self-contained’ .NET application, instead it has to have a ‘Target Framework’.  In order to implement this, you have to edit your .CSPROJ file and add the following setting under the property group:
    <SelfContained>false</SelfContained>
    When a console app is ‘self-contained’, the runtime for the target .NET version is included with the binary output when the console application is built.   However, this feature is not desirable because this would mean that your .NET runtime version is static.

If you follow the steps above your CoreHost standalone app can be forward compatible, but the problem is that the app will only allow the target .NET version to be loaded.  So, in our case since you built the app using the Pro SDK 3.1 this means that the CoreHost app is permanently linked to .NET 6.0 (or any minor release of .NET 6.0).  I added a small sample project called ‘CoreHostTest31Build’ to this post so you can see an implementation of a ‘forward compatible’ capable CoreHost app.
If you look at the .json files included with the corehost app you will notice that they are ‘bound’ to a specific .NET target of .NET 6.0, which means that the CoreHost app will not work under ArcGIS Pro 3.3 since Pro 3.3 requires .NET 8.0.  You will get this error:

> CoreHostTest31Build C:\Data\FeatureTest\FeatureTest.gdb

Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

You can see that the CoreHost app is trying to load .NET 8.0 because ArcGIS Pro 3.3 requires .NET 8.0.  However, the CoreHost app is bound to .NET 6.0 and hence the loading of .NET 8.0 fails.

This problem can be fixed by updating the .NET target framework version is the CoreHost’s CoreHost.deps.json file and CoreHost.runtimeconfig.json to .NET 8.0.  You can do this manually before you call your CoreHost app from the command line, or you can use the RunCoreHostApp command line utility to run your CoreHost app under ArcGIS Pro 3.1, 3.2, or 3.3.  This app will make the .json file changes for you:

RunCoreHostApp CoreHostTest31Build C:\Data\FeatureTest\FeatureTest.gdb

I included the RunCoreHostApp solution.  After you build the solution simply copy the executable into your CoreHost executable folder, now you have ‘forward compatibility’.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

It turns out that the DotNet.exe command line tool has a command line option to override the target .NET version by using the --fx-version command line switch.  Here is an example of the command line that overrides the target .NET to "8.0.5":

 

 

"C:\Program Files\dotnet\dotnet.exe" exec --fx-version "8.0.5" CoreHostTest31Build.dll

 

 

 The problem is that the new target .NET version has to be the exact version designation.  So in the example above it is not possible to simply specify "8.*" but instead one has to specify "8.0.5" or whatever the current patch level of .NET which has been installed on the machine.  Implementing this command line option alleviates the need for overwriting any .json configuration files.   I attached a new version of RunCoreHostApp that is using this DotNet command line option to run any CoreHost app with the correct version of .NET.