Based on what you said you will need to start up Outlook first before
starting Dynamics, or add tests to see in your addin when Outlook is
starting up with a UI.
In Startup() check for any Explorers. Instantiate an Explorers collection
and a NewExplorer() event handler. If there are no Explorers on startup just
have the addin sit and wait for NewExplorer if Outlook isn't exiting. If it
is then your addin should fire the disconnection event and start over when
Outlook is started with a UI.
When NewExplorer fires that's your cue that Outlook is starting with a UI so
then you instantiate all your objects.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://
www.slovaktech.com/products.htm
<snip>
Answers to your questions...
- Does Dynamics start Outlook itself using automation? When it does
so, if it
- does, do you see any Outlook UI or only what's shown in Dynamics? At
that
- point in Task Manager, Processes tab do you see Outlook.exe but no
Outlook
- UI?
Yes, Dynamics starts Outlook when it first opens. There is no UI shown
as Dynamics has its own UI to show Outlook items. When watching Task
Manager, outlook.exe appears for a few seconds then disappears.
- What about if Outlook was started first and then Dynamics? Does your
addin
- still run or does it get disabled then too?
The addin is not disabled if Outlook is running when Dynamics is
started.
- Are you checking for any Explorers in your startup code (Startup()
or
- OnConnection())? Do you correctly handle cases where there are no
Explorers
- or do you exit your addin or see any exceptions?
The following code appears within a Try Catch block. This code is
executed in the StartUp event.
// Bind to Explorers if bit flag is set.
if((_binding & OutlookBindingObject.Explorer) ==
OutlookBindingObject.Explorer)
{
// Our collection of Explorer Monitor wrappers.
_explorerMonitorList = new List<ExplorerMonitor>();
// For each existing Outlook Explorer, attach a new monitor object.
foreach(Outlook.Explorer explorer in _outlook.Explorers)
{
_explorerMonitorList.Add(new ExplorerMonitor(explorer,
_explorerMonitorList, false, this));
}
}
// Subscribe to the NewExplorer event. This allows us to assign a
monitor to any newly created Explorers.
_explorers = _outlook.Explorers;
_explorers.NewExplorer +=
delegate(Microsoft.Office.Interop.Outlook.Explorer explorer)
{
_explorerMonitorList.Add(new ExplorerMonitor(explorer,
_explorerMonitorList, true, this));
};
NOTE: The ExplorerMonitor class sinks events and adds items to the
commandbars.
- Is this VSTO or a shared addin (managed code) or unmanaged code?
What
- language and development platform?
VSTO
- Do you do something like oExplorer = application.ActiveExplorer();
in your
- code where it might fail if there are no Explorers?
No. Just the code shown above.
Other info...
Office 2003
VS2005
.NET 2.0
Hope this provides some additional insight.
Scott