我们有适用于 Excel 的 VSTO 插件,它可以在除一个系统之外的所有系统上运行,我从问题机器中收到以下错误。
加载此 Excel 扩展似乎存在问题,并且不知道为什么会在特定系统上发生这种情况。问题机器的错误如下,
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()
我们已尝试以下,
您可以使用 Windows 中的事件查看器查看安装或卸载 Office 解决方案时 Visual Studio Tools for Office Runtime 捕获的异常消息。您可以使用事件记录器中的这些消息来解决安装和部署问题。请阅读Office 解决方案的事件日志记录文章了解更多相关信息。
可以设置
VSTO_SUPPRESSDISPLAYALERTS
windows 环境变量,以便在加载 VSTO 加载项时启用详细的 Outlook 和 VSTO(Visual Studio Tools for Office)错误消息。请参阅如何启用 VSTO 错误/显示警报?。
我找到了问题的解决方案,在以下链接中给出 最后一步给出了解决方案,针对我的问题
真正的问题在于设置,其中存在与 ActiveX 设置相关的问题,可以通过 Excel 中的文件 > 选项 > 信任中心 > 信任中心设置按钮 > ActiveX 设置访问它。
在我的例子中,用户选择了禁用所有控件而不通知。这导致我在使用 VSTO 加载控件时出现问题。当用户选择“在以最小的限制启用所有控件之前提示我”时,这个问题得到了解决
功能区和侧面板上的控件畅通无阻,从而解决了我的问题。
您可以在链接上找到相同的建议 堆栈溢出:取消选择单选按钮 - 禁用所有控件而不通知。