Calling an Embedded Toolbox - Get executing Assembly Location

536
1
04-29-2021 09:01 AM
AndersBerg1
New Contributor II

Hi,

I have been following the instructions here, to embed a toolbox and it works fine for embedding.

https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-content-and-image-resources#embedding-toolboxes


https://community.esri.com/t5/arcgis-pro-sdk-questions/embedding-toolboxes-in-arcgis-pro/td-p/794965...

I have been using the code snippet that I found at the end of this post by  to reference the embedded toolbox.

https://community.esri.com/t5/arcgis-pro-sdk-questions/embedding-my-custom-toolbox-within-my-arcpro-...

However, this code returns a path with  the assembly location. like this

C:\Users\username\AppData\Local\ESRI\ArcGISPro\AssemblyCache\{243459f3-4fc8-4c96-ae0c-139814c9750e}

and it needs to be 

C:\Users\username\AppData\Local\ESRI\ArcGISPro\Toolboxes\{243459f3-4fc8-4c96-ae0c-139814c9750e}

I have modified my code, to replace the string "AssemblyCache" and this works, but is there a cleaner way to do this? my code is below

string assemblyfolderpath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string finalpath = assemblyfolderpath.Replace("AssemblyCache", "Toolboxes");
string tool_path = System.IO.Path.Combine(finalpath,@"toolboxes\Default.tbx\CreateScenario");

Thank you in advance for your help

 

 

0 Kudos
1 Reply
AntDevEsk
New Contributor

After trying to resolve this for a while i found that once you have embedded the toolbox you can access it like a system toolbox, i.e  <toolboxName>.<toolName> you dont need to know its full path

0 Kudos