OnStartupComplete never fires for Csharp Outlook Add-in

  • Thread starter Thread starter Irregular
  • Start date Start date
I

Irregular

I have an addin written in C# that works fine on two different home
machines, but doesn't work on another two work machines.

It's based directly on the template in

HOW TO: Build an Office COM Add-in by Using Visual C# .NET
http://support.microsoft.com/?id=302901

OnConnect fires, Extensibility.ext_ConnectMode.ext_cm_Startup is set, but
OnStartupComplete never fires. The sample fires the OnStartupComplete
function directly if Extensibility.ext_ConnectMode.ext_cm_Startup isn't set,
and I could cheat and fire it from OnConnect, but I assume that a) there's a
reason it's not working, and b) it might be dangerous to possibly fire it
twice.

Any suggestions on how I can track down the broken bit on the two other
machines, or why this might happen?
 
Looks like I made some incorrect assumptions about what happens and when.

None of the Debug.WriteLines fire when the function collapses for whatever
reason.

I had cast the applicationObject to
Microsoft.Office.Interop.Outlook.Application in OnConnect, and that
invalidated some of the calls to InvokeMember later in the sample (I think -
I'm still working this out, but commenting the block apart from the debug
statements executes fine :) )

If I find a definitive answer, I'll post back. Interesting it works
elsewhere....
 
Problem gets more interesting.

The same code now works on 3 of 5 machines, but I'm still without any reason
for failure. The collapse of the assembly appears silent, at least when
debugging through Visual Studio by launching the Outlook process.

Any attempt to access the CommandBars (most recent, CommandBars.Count)
results in this behaviour, but I can do gymnastics with the ActiveExplorer()
and other properties of the application object.

The following code is enough to force a complete collapse of the
OnStartupComplete method.

This would be cool, but unfortunately without a button, I'm missing a user
interface! (Maybe a menu item or property sheet instead would work
reliably...)

public void OnStartupComplete(ref System.Array custom) {

System.Diagnostics.Debug.WriteLine("OnStartupComplete");

Microsoft.Office.Core.CommandBars oCommandBars;

Microsoft.Office.Core.CommandBar oStandardBar;

// this bit causes the whole function to disappear...



oCommandBars = applicationObject.ActiveExplorer().CommandBars;

// but the next line is perfectly acceptable, so I definitely have an
applicationObject. It just doesn't like being touched in the CommandBars
region.

// Debug.WriteLine("Current Folder: " +
applicationObject.ActiveExplorer().CurrentFolder.Name);
 
Back
Top