Add-in problems when Outlook loaded within another application

J

js.buck

Hi,

I am experiencing a problems with an addin I created for Outlook 2003.

The client is running Microsoft Dynamics (Great Plains) which has a
main page that will display information from Outlook. Every time they
start MS Dynamics, the LoadBehavior registry key for my Outlook addin
is changed from 3 to 2. If I reset to 3, they can run Outlook with our
addin and it works fine. However, the next time MS Dynamics is started
the LoadBehavior is set back to 2 again.

I suspect this issue has something to do with loading Office
applications from within another process. Does anyone have any insight
as to how to make an addin work correctly in this scenario?

Thanks.
Scott
 
K

Ken Slovak - [MVP - Outlook]

There's no real way to tell based on the information provided.

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?

What about if Outlook was started first and then Dynamics? Does your addin
still run or does it get disabled then too?

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?

Is this VSTO or a shared addin (managed code) or unmanaged code? What
language and development platform?

Do you do something like oExplorer = application.ActiveExplorer(); in your
code where it might fail if there are no Explorers?
 
J

js.buck

There's no real way to tell based on the information provided.

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?

What about if Outlook was started first and then Dynamics? Does your addin
still run or does it get disabled then too?

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?

Is this VSTO or a shared addin (managed code) or unmanaged code? What
language and development platform?

Do you do something like oExplorer = application.ActiveExplorer(); in your
code where it might fail if there are no Explorers?

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm




I am experiencing a problems with an addin I created for Outlook 2003.
The client is running Microsoft Dynamics (Great Plains) which has a
main page that will display information from Outlook. Every time they
start MS Dynamics, the LoadBehavior registry key for my Outlook addin
is changed from 3 to 2. If I reset to 3, they can run Outlook with our
addin and it works fine. However, the next time MS Dynamics is started
the LoadBehavior is set back to 2 again.
I suspect this issue has something to do with loading Office
applications from within another process. Does anyone have any insight
as to how to make an addin work correctly in this scenario?
Thanks.
Scott- Hide quoted text -

- Show quoted text -

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
 
K

Ken Slovak - [MVP - Outlook]

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.




<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
 
J

js.buck

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

It appears that the addin is getting disabled before Startup is even
called. I put a messagebox in the StartUp event and it never shows
when run from Dynamics. Could this be a permissions/security thing? Is
Dynamics attempting to load Outlook into its process and there are
insufficient rights to run the addin assemblies?
 
K

Ken Slovak - [MVP - Outlook]

If Startup() is never even firing then possibly Dynamics is preventing any
other addins from loading by toggling their Connect bit flags. Do any other
addins run when Dynamics starts Outlook?

I've never used or programmed against Dynamics, is there a forum for that
software where you can ask about its behavior?

The other possibility is that VSTO is preventing the addin from starting up
due to a lack of UI (although my VSTO addins do respond in those
conditions).





It appears that the addin is getting disabled before Startup is even
called. I put a messagebox in the StartUp event and it never shows
when run from Dynamics. Could this be a permissions/security thing? Is
Dynamics attempting to load Outlook into its process and there are
insufficient rights to run the addin assemblies?
 
J

js.buck

If Startup() is never even firing then possibly Dynamics is preventing any
other addins from loading by toggling their Connect bit flags. Do any other
addins run when Dynamics starts Outlook?

I've never used or programmed against Dynamics, is there a forum for that
software where you can ask about its behavior?

The other possibility is that VSTO is preventing the addin from starting up
due to a lack of UI (although my VSTO addins do respond in those
conditions).

--
Ken Slovak
[MVP - Outlook]http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Optionshttp://www.slovaktech.com/products.htm



It appears that the addin is getting disabled before Startup is even
called. I put a messagebox in the StartUp event and it never shows
when run from Dynamics. Could this be a permissions/security thing? Is
Dynamics attempting to load Outlook into its process and there are
insufficient rights to run the addin assemblies?

This issue has been resolved. Turns out that there is a bug in the
original release of the VSTO 2005 SE runtime. This impacted Office
2003 applications developed with this version of VSTO. If you use VSTO
2005 (not SE) or Office 2007 you are ok. Microsoft has issued a hotfix
available here:

http://www.microsoft.com/downloads/...CB-B43E-4B09-82F6-8BA3F7B5E935&displaylang=en

I installed this hotfix and my addin functions as expected. Thanks for
all of your help in attempting to troubleshoot this problem.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top