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
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:
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’.
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.