ESRI sample errors when loading into VS

451
2
10-20-2022 11:00 AM
JohnnyHarley12
New Contributor II

New to VS and SDK. I want to load this ESRI example Link into Visual Studio regarding custom map layouts. I downloaded Visual Studio 2022 and installed the ArcGIS Pro SDK extension from the online store. There are a few classes that error when trying to build. Shouldnt an ESRI sample be 100% compatible if Visual Studio is up to date?

0 Kudos
2 Replies
CharlesMacleod
Esri Regular Contributor

First thing to check are your assembly references. Check under Dependencies\Assemblies. A common issue with sharing addin code is that the assembly reference paths are can be different from machine to machine.

If this is the problem then simply change the assembly locations in your copy of the project to the correct location based on the install path of _your_ local ArcGIS Pro.

We also provide a utility that will do this for you automatically. It is included as part of the 'ArcGIS Pro SDK Utilities` visx. Install that (if u haven't already) and when u right click in the VS project window there will be a "Pro Fix References" menu option. Simply click on it to have all assembly paths, etc. be fixed automatically.

More information here:

https://github.com/Esri/arcgis-pro-sdk/wiki#arcgis-pro-sdk-for-net-utilities 

 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

@JohnnyHarley12 , it looks like the instructions are missing an important step after you insert the layout construction code into the OnClick method.   You can let Visual Studio fix the problem for you by right clicking on the error and selecting "Quick Actions and Refactorings ..." 

Wolf_0-1666699317771.png

Or you can simply fix the OnClick method definition to this:

protected override async void OnClick()

We'll fix the issue for the next release.

0 Kudos