Office COM外接程序和VSTO外接程序之间存在冲突

Office COM外接程序和VSTO外接程序之间存在冲突,com,vsto,ms-office,add-in,Com,Vsto,Ms Office,Add In,我已经创建了一个简单的Office Com加载项,它与公司计算机上的其他PowerPoint加载项一起使用。每次PowerPoint启动AccessViolationException时,只要我在AfterPresentationOpen事件中访问windows count属性,就会发生异常(请参见下面的代码) 为了缩小问题的范围,我创建了两个空白插件解决方案(Office COM和VSTO插件)。我在AfterPresentationOpen方法中放置了一个断点,每次在名为VSTA_Main的

我已经创建了一个简单的Office Com加载项,它与公司计算机上的其他PowerPoint加载项一起使用。每次PowerPoint启动AccessViolationException时,只要我在AfterPresentationOpen事件中访问windows count属性,就会发生异常(请参见下面的代码)

为了缩小问题的范围,我创建了两个空白插件解决方案(Office COM和VSTO插件)。我在AfterPresentationOpen方法中放置了一个断点,每次在名为VSTA_Main的线程上命中该断点时,都会抛出此异常。此外,我的try-catch块没有捕获此异常。一旦我禁用了一个特定的第三方插件,一切都像一个符咒一样工作,在主线程上点击断点,我就可以读取count属性

我使用的是Windows7和Office2010(都是x64)。顺便说一句,所有其他PowerPoint事件都是在我的代码中的“VSTA_Main”线程上引发的。我认为所有事件实际上都应该在我的appdomain线程上引发

有人知道我如何处理此错误并避免与此加载项发生任何冲突吗

var windows = presentation.Windows; 
using (new ComObject(windows)) 
{ 
       try 
       {                 
        var count = windows.Count; 
        if (count == 0) 
            return; 
       } 
       catch (AccessViolationException) 
       {                 
       } 
}
请在调用堆栈下面找到

ntdll.dll!NtWaitForSingleObject()  + 0xa bytes  
    KernelBase.dll!WaitForSingleObjectEx()  + 0x9c bytes    
    ntdll.dll!RtlpExecuteHandlerForException()  + 0xd bytes 
    ntdll.dll!RtlDispatchException()  + 0x38c bytes 
    ntdll.dll!KiUserExceptionDispatcher()  + 0x2e bytes 
    PPCORE.DLL!000007fee75fa918()   
    [Frames below may be incorrect and/or missing, no symbols loaded for PPCORE.DLL]    
    PPCORE.DLL!000007fee75254ac()   
    PPCORE.DLL!000007fee7525475()   
    [Managed to Native Transition]  
TestAddin.DLL!TestAddin.AddinModule.adxPowerPointEvents_AfterPresentationOpen(object sender, object hostObj) Line 116 + 0x20 bytes  C#
    AddinExpress.MSO.2005.DLL!AddinExpress.MSO.ADXPowerPointAppEvents.DoAfterPresentationOpen(object presentation) + 0x6b bytes 
    AddinExpress.MSO.2005.DLL!AddinExpress.MSO.ADXAddinModule.PowerPointApplicationEvents_SinkHelper.AddinExpress.MSO.IPowerPointApplicationEvents.AfterPresentationOpen(object presentation) + 0x56 bytes  
    [Native to Managed Transition]  
    [Native to Managed Transition]  
    [Appdomain Transition]  
    PPCORE.DLL!000007fee7499b05()   
    PPCORE.DLL!000007fee74999c5()   
    PPCORE.DLL!000007fee74461ec()   
    PPCORE.DLL!000007fee74b0ca0()   
    PPCORE.DLL!000007fee744256c()   
    PPCORE.DLL!000007fee7442519()   
    PPCORE.DLL!000007fee74f9988()   
    [Managed to Native Transition]  
    AW PowerPoint 2010.DLL!AW_PowerPoint_2010.rbnAW.AddShapeToGallary(Microsoft.Office.Tools.Ribbon.RibbonGallery galrShapes) + 0xc6a bytes 
    AW PowerPoint 2010.DLL!AW_PowerPoint_2010.rbnAW.rbnOW_Load(object sender, Microsoft.Office.Tools.Ribbon.RibbonUIEventArgs e) + 0xd3 bytes   
    Microsoft.Office.Tools.Common.Implementation.dll!Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.CreateRibbon(string ribbonId, object context) + 0x139 bytes    
    Microsoft.Office.Tools.Common.Implementation.dll!Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.GetRibbon(Microsoft.Office.Core.IRibbonControl control) + 0x104 bytes  
    Microsoft.Office.Tools.Common.Implementation.dll!Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.Invoke(Microsoft.Office.Tools.Ribbon.RibbonComponentCallback callback, object[] args) + 0x80 bytes 
    Microsoft.Office.Tools.Common.Implementation.dll!Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.System.Reflection.IReflect.InvokeMember(string name, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, object target, object[] args, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, string[] namedParameters) + 0xf2 bytes   
    [Native to Managed Transition]  
    [Appdomain Transition]  
    MSO.DLL!000007fee40617ea()  
    MSO.DLL!000007fee406169b()  
    MSO.DLL!000007fee42f6fd2()  
    MSO.DLL!000007fee4423ae9()  
    MSO.DLL!000007fee3f85d24()  
    MSO.DLL!000007fee3f74b7c()  
    MSO.DLL!000007fee3f748e5()  
    MSO.DLL!000007fee4060d95()  
    MSO.DLL!000007fee4060c73()  
    MSO.DLL!000007fee405d57c()  
    MSO.DLL!000007fee3f8c7b8()  
    MSO.DLL!000007fee3f80671()  
    MSO.DLL!000007fee3f6d929()  
    MSO.DLL!000007fee3f80476()  
    MSO.DLL!000007fee3f80386()  
    MSO.DLL!000007fee3f8024e()  
    MSO.DLL!000007fee3f7f038()  
    MSO.DLL!000007fee3f7e7cc()  
    MSO.DLL!000007fee3f7d4aa()  
    MSO.DLL!000007fee3f7e56b()  
    MSO.DLL!000007fee3f8114c()  
    PPCORE.DLL!000007fee73ff6d5()   
    PPCORE.DLL!000007fee73f86ad()   
    PPCORE.DLL!000007fee73f6eac()   
    PPCORE.DLL!000007fee73f6c4d()   
    PPCORE.DLL!000007fee73f6120()   
    user32.dll!UserCallWinProcCheckWow()  + 0x11d bytes 
    user32.dll!CallWindowProcAorW()  + 0x78 bytes   
    user32.dll!CallWindowProcW()  + 0x18 bytes  
    comctl32.dll!CallOriginalWndProc()  + 0x1d bytes    
    comctl32.dll!CallNextSubclassProc()  + 0x8c bytes   
    comctl32.dll!DefSubclassProc()  + 0x7c bytes    
    MSO.DLL!000007fee3f2afba()  
    MSO.DLL!000007fee3f2a34a()  
    comctl32.dll!CallNextSubclassProc()  + 0x8c bytes   
    comctl32.dll!MasterSubclassProc()  + 0xe7 bytes 
    user32.dll!UserCallWinProcCheckWow()  + 0x11d bytes 
    user32.dll!DispatchClientMessage()  + 0x5f bytes    
    user32.dll!__fnDWORD()  + 0x2d bytes    
    ntdll.dll!KiUserCallbackDispatcherContinue()    
    user32.dll!ZwUserMessageCall()  + 0xa bytes 
    user32.dll!SendMessageWorker()  - 0x44b8 bytes  
    user32.dll!RealDefWindowProcWorker()  - 0x4efc bytes

听起来您的外接程序中有一个出现了如下所述的线程问题: