Outlook error -

Mar 6, 2015 at 6:31 AM
Edited Mar 6, 2015 at 6:32 AM

When trying to run the following code during the COMAddin startup, it gave the error
"Target instance is not running" at the line (in bold) where I'm trying to the active instance.
Any ideas what could cause this error?
    private void Addin_OnStartupComplete(ref Array custom)
                /* Exception happened here */
                Outlook.Application outApp = NetOffice.OutlookApi.Application.GetActiveInstance(true);

                Office.CommandBar commandBar = null;
                Office.CommandBarButton commandBarSaveBtn = null;

                // add a new toolbar
                commandBar = outApp.ActiveExplorer().CommandBars.Add("MyOutlook", MsoBarPosition.msoBarTop, false, true);
                commandBar.Visible = true;

                // add a button to the toolbar
                commandBarSaveBtn = (Office.CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, System.Type.Missing, true);
                commandBarSaveBtn.Style = MsoButtonStyle.msoButtonIconAndCaption;
                commandBarSaveBtn.Caption = "Save to Local";
                commandBarSaveBtn.FaceId = 3;
                commandBarSaveBtn.ClickEvent += new Office.CommandBarButton_ClickEventHandler(outlookSaveBtn_Click);