Search code examples
c#excelvstooffice-addinsexcel-addins

Excel VSTO refuses to load on particular machine


We have VSTO addin for Excel, and it is working on all system except one, I got following error from problem machine.

It seems that there is problem of loading this Excel extension, and there is no clue why this will happen on particular system. Error from problem machine is as follows,

System.Runtime.InteropServices.COMException (0x800A03EC): Cannot insert object.
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32\[\] aWrapperTypes, MessageData& msgData)
at Microsoft.Office.Interop.Excel.Shapes.AddOLEObject(Object ClassType, Object Filename, Object Link, Object DisplayAsIcon, Object IconFileName, Object IconIndex, Object IconLabel, Object Left, Object Top, Object Width, Object Height)
at Microsoft.Office.Tools.Excel.ControlCollectionImpl.CreateWrapperAndGetCookie(String name, Double left, Double top, Double width, Double height, Boolean anchor, \_OLEObject& outObject)
at Microsoft.Office.Tools.Excel.ControlCollectionImpl.InternalAddOtherControl(Control control, Double left, Double top, Double width, Double height, String name, Boolean anchor)
at Microsoft.Office.Tools.Excel.ControlCollectionImpl.AddControl(Control control, Range range, String name)
at TechnicalCalculation.Sheet1.LoadSchedulerUserControl()
at TechnicalCalculation.ThisWorkbook.InitializeService()
at TechnicalCalculation.ThisWorkbook.ThisWorkbook_Startup(Object sender, EventArgs e)
at Microsoft.Office.Tools.Excel.WorkbookImpl.OnStartup()
at Microsoft.Office.Tools.Excel.WorkbookImpl.WorkbookExtensionImpl.Microsoft.Office.Tools.EntryPoint.OnStartup()
at Microsoft.Office.Tools.Excel.WorkbookBase.OnStartup()
at TechnicalCalculation.ThisWorkbook.FinishInitialization()
at Microsoft.Office.Tools.Excel.WorkbookBase.Microsoft.Office.Tools.EntryPoint.FinishInitialization()
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()

We have tried following,

  1. Try and fulfill any dependencies, which are fulfilled.
  2. VSTO is packaged in a setup file, we have uninstalled and reinstalled it.
  3. VSTO, it can emit logs, but logs are not emitted while loading VSTO is getting loaded. It seems that before any code execution from VSTO it is restricted to load with Excel.

Solution

  • Real problem was in settings, where there was an issue related to ActiveX Settings, it can be accessed in Excel from File > Options > Trust center > Trust center settings button > ActiveX setting.

    In my case user selected "Disabled all the controls without notification." This was causing me issue while loading my controls using VSTO. This got solved when user selected "Prompt me before enabling all controls with minimal restrictions"

    This unblocked controls on ribbon and on side panel, thus solved my problem.

    You can find same suggestion on the link Stack overflow: Deselect radio button-Disabled all the controls without notification.