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?
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.
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.
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.