Reference Button Class in Different Assembly

189
5
01-26-2021 09:26 AM
KrisCulin
New Contributor III

Hello,

We currently have two products that integrate with ArcGIS Pro.  There is a lot of feature overlap and to avoid duplicating code, we'd like to share button classes.

Each product is setup as a configuration (using the /config:<name> command line parameter) and each has its own config.daml file.

We currently have an add-in project with a config.daml file that defines shared buttons and references classes in the same project. These shared buttons are referenced from the config.daml file in the two product configurations.

However, we'd like to have these shared button classes in a project that is *not* an add-in project.  Is this possible?

We understand that images must be in an add-in which is fine.  It's the buttons, menus, conditions, etc. that we need to share but would like not to be in an add-in.

If you need any clarification, please ask.

TIA,

Kris

Reply
0 Kudos
5 Replies
KirkKuykendall1
Occasional Contributor II

Have you tried putting shared code into an assembly that loads first? 

https://www.esri.com/arcgis-blog/products/arcgis-pro/uncategorized/manage-arcgis-pro-add-in-loading/

 

Reply
0 Kudos
KrisCulin
New Contributor III

Thanks for the link @KirkKuykendall1.  I was hoping we'd be able to do something without using an add-in.  Or at least have the button classes in a non-addin project that can be referenced from the add-in's config.daml file.  There is an assembly attribute for a button but specifying the other assembly doesn't seem to make it work.

ArcGISpro.dll (non-addin assembly where button classes are located)

ArcgISPro.UI.dll (add-in project with config.daml file)

I would like to reference a button class defined in ArcGISPro.dll in the ArcGISPro.UI.dll

The goal here is to keep duplicate code to an absolute minimum.  Why have a button class called "EditGeoTablesButton" in both products when it can be defined once in ArcGISPro.dll, referenced via a button definition in ArcGISPro.UI.dll and then that button used in the two product's config.daml files.  The two products simply reference the button in the add-in, the add-in config.daml file finds the button class in ArcGISPro.dll.

Kris

Reply
0 Kudos
KirkKuykendall1
Occasional Contributor II
Reply
0 Kudos
KrisCulin
New Contributor III

That is currently not an option at this time.

Kris

Reply
0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi @KrisCulin ,

It is possible to have your custom button class in your custom class library.

How I have done before is 

1. Make sure shared class library has ArcGIS pro nugget package reference. I follow this guide and sample

arcgis-pro-sdk-community-samples/Map-Exploration/TimeNavigation at 19a330dcbe57cdbbde7f0762e9321aa7b...

ProGuide Ribbon Tabs and Groups · Esri/arcgis-pro-sdk Wiki · GitHub

2. ProGuide ArcGIS Pro Extensions NuGet · Esri/arcgis-pro-sdk Wiki · GitHub , I make nugget package management as package referece

3. For config.daml, for customcontrol tag, the two main attributes I used are assembly tag for dll name, className for your customcontrol classname. button should be in same concept as well.

 

If you can share your customized button class, we can try and advise you better.

 

Reply
0 Kudos