Module overrides are not being called

225
3
12-07-2021 06:20 AM
DarrenAndariese
New Contributor

Darren Andariese - 

ArcGis Pro version 2.8.3, SDK 2.9 for .Net

Hello All

    I'm having an issue with my Add-In for ArcGis Pro. I'm trying to override the Initialize method in the Module Class (Which my module is inherited from) and the Initialize method is not being called. I want to add some event handlers to warn users when they attempt to open a project using the Open command in ArcGis Pro Desktop. I want user to use my Add-In to open thier project. I want my module to initialize these events when ArcGis Pro opens. In my DAML, I set, autoLoad="true". But my overridden Initialize method is never being run (Confirmed when running in debug). Below is some of my code from the DAML and my module class:

DAML:

<ArcGIS defaultAssembly="GraphicsFireDeskAddInPro.dll" defaultNamespace="GraphicsFireDeskAddInPro" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{1634e85e-8fa3-4db6-958c-b2e5f3ed133e}" version="1.0" desktopVersion="2.8.3">
<Name>GraphicsFireDeskAddInPro</Name>
<Description>GraphicsFireDeskAddInPro description</Description>
<Image>Images\AddinDesktop32.png</Image>
<Author>andariesed</Author>
<Company>Acme</Company>
<Date>4/5/2021 7:37:53 AM</Date>
<Subject>Framework</Subject>
<!-- Note subject can be one or more of these topics:
Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->
</AddInInfo>
<modules>
<insertModule id="GraphicsFireDeskAddInPro_Module" className="GFDC_Module" autoLoad="true" caption="Graphics Fire Desk Configuration" >
<!-- uncomment to have the control hosted on a separate tab-->
<tabs>
<tab id="GraphicsFireDeskAddInPro_Tab1" caption="Graphics Fire Desk" >
<group refID="GraphicsFireDeskAddInPro_Group1" />
<group refID="GraphicsFireDeskAddInPro_Group2" />
<group refID="GraphicsFireDeskAddInPro_Group3" />
</tab>
</tabs>

 

Module:

using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using Rfmss.GraphicsFireDeskAddInPro.Scripts.ViewModel.Extension;
using Rfmss.GraphicsFireDeskAddinPro.Scripts.View.Login;
using Rfmss.GraphicsFireDeskAddInPro.Scripts.Utility;
using Rfmss.GraphicsFireDeskAddInPro.Scripts.ViewModel.Error;
using System.Windows.Input;
using Rfmss.GraphicsFireDeskAddinPro.Scripts.View.Error;
using Rfmss.GraphicsFireDeskAddinPro.Scripts.View.Background;
using Rfmss.Core.Logging;
using Rfmss.GraphicsFireDeskAddinPro.Scripts.ViewModel.ManageRgl;
using Rfmss.GraphicsFireDeskAddinPro.Scripts.Utility;

namespace Rfmss.GraphicsFireDeskAddInPro
{
   internal class GFDC_Module : Module
   {
       private static GFDC_Module _this = null;

/// <summary>
/// Retrieve the singleton instance to this module here
/// </summary>
public static GFDC_Module Current
{
get
{
    return _this ?? ( _this = ( GFDC_Module )FrameworkApplication.FindModule(     "GraphicsFireDeskAddInPro_Module" ) );
}
}
protected override bool Initialize()
{
   return base.Initialize();
}

0 Kudos
3 Replies
KirkKuykendall1
Occasional Contributor III

With 2.9 SDK running 2.9 desktop I

  1. added a new Addin Module,
  2. added an override for Initialize in Module1.cs
  3. Changed autoLoad=true in the Config.daml
  4. set a breakpoint in the Intialize() override
  5. Run Pro from VS in debug mode

When pro started it hit my break point.

If you do these steps (with a new module) and get different results, I suspect it might have something to do with running 2.9 SDK with 2.8 desktop. (I've always wondered how compatible this is).

 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I tested it too and it works.  Looking at your daml it seems to me that your namespace doesn't match what you're using in your code.

daml:

defaultNamespace="GraphicsFireDeskAddInPro"

doesn't match the code's namespace: 

namespace Rfmss.GraphicsFireDeskAddInPro

 

0 Kudos
KirkKuykendall1
Occasional Contributor III

Actually ... none of the OnPane overrides for Module are being called for me when I switch active panes - Init and OnUpdate are being called though.  Using 2.9.0

0 Kudos