.NET Project Namespace and Module Name

402
6
03-20-2020 12:31 PM
AbelPerez
Occasional Contributor II

Went through the tutorial on building my first add-in for ArcGIS Pro.

Two things I have a question about:

1. I typically change all my project's namespace to something like MyCompany.MyDepartment.AddInName. This seems to break my add-in. Is this supported and what changes would I need to make to my Config.daml to support the custom namespace?

2. I also change most default modules to something more intuitive. So I changed Module1 to MdlMyAddin. This also seems to break the add-in. Is this supported and what do I need to change in the Config.daml to support the custom module name?

Abel

0 Kudos
6 Replies
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Abel Perez‌,

For your question 1 : changing namespace: 

Better change defaultNamespace property at Config.daml, and all the other xaml file attribute x:Class="......" and d.DataContext binding.

And better check all class reference especially in controls tag of Config.daml

Be careful about the assembly name as well. I would suggest to create the project with your desire namespace can make your life easier.

Question 2: changing module class name.

Yes, I used to change it as well, You need to change className attribute in Insertmodule element of Config.daml with your new class name. To change class name in Visual studio , press f2 by selecting and change the name. That shall alert you to update reference links. and then change your config.daml. Make sure insertmoule id in config.daml and const string ModuleName value in your module class are the same as well. ***, After I change class name, I normally change that id as well, in case you might want to change that id also. 

Let me know how's go. 

AbelPerez
Occasional Contributor II

Not really sure I understand what you are suggesting.

0 Kudos
CharlesMacleod
Esri Regular Contributor

This section of the Pro Concepts Framework may help: ProConcepts-Framework#module-plug-in. This is basically what Than is describing.

Some debugging tips are here: ProGuide-Diagnosing-ArcGIS-Pro-Add-ins

AbelPerez
Occasional Contributor II

OK I think I get it now. I did read the link for the framework but must have missed that part.

Here is how I tweaked my Config.daml to make this work:

<ArcGIS defaultAssembly="MyAddin.dll" defaultNamespace="MyCompany.MyDepartment.MyAddin">

<insertModule id="MyAddin_Module" className="ModuleMain" autoLoad="false" caption="My Addin Module">

0 Kudos
CharlesMacleod
Esri Regular Contributor

Ideally, you want the defaultAssembly and defaultNamespace attributes to _match_ the corresponding properties in your visual studio project (i.e. Application properties tab, Assembly name, Default namespace).

If you change the name of your assembly or default namespace in Visual Studio then be sure to update your Config.daml to keep it in sync.

Additionally, depending on how you have your project arranged and which project folders you organize your content into, you may also need to change the className attribute on your various DAML entries if you rename classes or move them around. If a given control or dockpane or whatever is _not_ in the default namespace then you must always fully qualify the className attribute. The SDK templates do this for you automatically when they first generate a given DAML entry but if you refactor your add-in content then it is your responsibility to keep your Config.daml up to date.

In your example, say you were to refactor your Module cs file to a different namespace (or rename it or....) then you would need to go into the Config.daml and change the "<module className" attribute to match - fully qualifying the className if your "refactored" ModuleMain were to no longer be in the MyCompany.MyDepartment.MyAddin namespace (i.e. your current default).

0 Kudos
AbelPerez
Occasional Contributor II

Cool. I think I am on board. I think all this info will definitely help me move forward.

0 Kudos