Select to view content in your preferred language

Struggling to auto-load and initialize a module

163
2
Jump to solution
11-26-2024 11:27 AM
DanNarsavage_IDWR
Regular Contributor

I just modified our module for ArcGIS Pro v3.3 (excerpt of Config.daml below) to auto-load.

 

 

<modules>
  <insertModule id="WREdit_Module" className="WREditModule" autoLoad="true" caption="WREdit">
    <tabs>

 

 

Despite this, the static constructor doesn't run any earlier than it previously did--for example, until I click a button defined within the module.

I also recently created a non-static constructor and overloads of Initialize() & Uninitialize().

 

 

public WrEditModule()
{
    LogExceptionToFile(new Exception("ctor"));
    Log.Information("ctor");
    _wrEditLauncherPipeServer = GetDependency<WrEditLauncherPipeServer>();
    _wrEditLauncherPipeServer.Run();
}

protected override bool Initialize() //Called when the Module is initialized.
{
    LogExceptionToFile(new Exception("Initialize"));
    Log.Information("init");
    _wrEditLauncherPipeServer = new WrEditLauncherPipeServer();
    _wrEditLauncherPipeServer.Run();
    return base.Initialize();
}

protected override void Uninitialize() //Called when the Module is shut down.
{
    LogExceptionToFile(new Exception("Uninitialize"));
    Log.Information("uninit");
    _wrEditLauncherPipeServer.Stop(); // Stop the pipe server
    base.Uninitialize();
}

 

 

But none of that stuff ever happens.  Everything we've put in there so far is static (following the convention described in the doc), but I'd expect that an API documented with non-static members would . . . y'know . . . instantiate an object at some point. What am I missing?

I could handle this statically if necessary, but I need to run the `_wrEditLauncherPipeServer.Stop()` method before ArcGIS Pro is closed.  How can I ensure that happens in a static context?

0 Kudos
1 Solution

Accepted Solutions
DanNarsavage_IDWR
Regular Contributor

TL;DR: Class names in the DAML are case-sentitive.

Thanks for your reply!  Project target was already at 8.0, and I changed the desktopVersion value from "3.3.0" to "3.3.52636" based on what I saw in my "Add/Remove Programs" interface (although Pro itself simply reported 3.3.0).  Those changes had no effect.

But your suggestion prompted me to inspect the DAML more closely and (after many other ineffectual attempts) I noticed that the module class is declared in C# as "WrEditModule" while it is cited in the DAML as "WREditModule".  Changing the DAML to match the C# did the trick (after rolling back all my other changes). 

Good grief, every bit of five hours of work to change one character.  Reminds me of Joel Spolsky's wisdom.

View solution in original post

0 Kudos
2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

I have modified ArcGIS Pro SDK Community sample InspectorTool. I have changed autoload to true. It works as expected. Initialize event arises before ArcGIS Pro starts (on splash screen). Check project target framework (.NET8.0) version and  desktopVersion in config.daml file.

 

GKmieliauskas_0-1732693273806.png

 

0 Kudos
DanNarsavage_IDWR
Regular Contributor

TL;DR: Class names in the DAML are case-sentitive.

Thanks for your reply!  Project target was already at 8.0, and I changed the desktopVersion value from "3.3.0" to "3.3.52636" based on what I saw in my "Add/Remove Programs" interface (although Pro itself simply reported 3.3.0).  Those changes had no effect.

But your suggestion prompted me to inspect the DAML more closely and (after many other ineffectual attempts) I noticed that the module class is declared in C# as "WrEditModule" while it is cited in the DAML as "WREditModule".  Changing the DAML to match the C# did the trick (after rolling back all my other changes). 

Good grief, every bit of five hours of work to change one character.  Reminds me of Joel Spolsky's wisdom.

0 Kudos