Add-in OnLoad fails to execute when opening MXD from command line

2967
11
02-02-2014 03:16 PM
jgers
by
New Contributor
OnLoad is supposed to be called when opening a document with a persisted stream. But, when I try loading the MXD from the command line  (ie. arcmap.exe somemapdoc.mxd), OnLoad never executes in my Add-in.  Is there a work around for this issue?
0 Kudos
11 Replies
DuncanHornby
MVP Notable Contributor
OK obvious first question to ask: does the addin extension onLoad run when you open ArcMap and then your MXD?
0 Kudos
RichardWatson
Frequent Contributor
Did your add-in previously save information in this map document?

In other words was OnSave called and you added data and then saved the mxd?

I have not used this before for add-ins but have some experience with classic IExtension objects.
0 Kudos
jgers
by
New Contributor
OK obvious first question to ask: does the addin extension onLoad run when you open ArcMap and then your MXD?


Yes, OnLoad does run if you open the mxd that way.
0 Kudos
jgers
by
New Contributor
Did your add-in previously save information in this map document?

In other words was OnSave called and you added data and then saved the mxd?

I have not used this before for add-ins but have some experience with classic IExtension objects.


Yes, the data is saved into the mxd with OnSave.  I am able to read it back(OnLoad executes) if I load the mxd from an already open session of ArcMap.   This issue only occurs if the mxd is loaded through the command line.
0 Kudos
RichardWatson
Frequent Contributor
Did you do this?

http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#/Advanced_add_in_concep...

Delay loading

By default, the assemblies associated with add-in buttons and tools are not loaded until the corresponding item on a toolbar or menu is clicked by the user. This behavior helps conserve application memory and other resources. Since the enabled state of an add-in button or tool is controlled by the OnUpdate method within code, the button or tool will initially appear enabled. If you need tighter control over the initial enabled state of a button or tool, you need to override the default behavior and force the item to load at startup by setting the onDemand Extensible Markup Language (XML) attribute to false.
0 Kudos
jgers
by
New Contributor
That doesn't help because it's for Add-in buttons and tools.
0 Kudos
LeoDonahue
Occasional Contributor III
Ok, what kind of Add-in do you have?
0 Kudos
jgers
by
New Contributor
I am beginning to think this is a bug.
0 Kudos
ErinBrimhall
Occasional Contributor II
This may or may not be related... but I've seen issues with Add-ins loading and events firing when ArcMap is launched through some indirect means (e.g. by another application, by command prompt, etc.).  It boiled down to security constraints defined in local and domain group policies.

It's not clear if yours is the same kind problem, but just thought I'd throw this info out there in case it can get you looking in the right area.
0 Kudos