Office COM加载项与VSTO加载项之间的冲突

时间:2012-06-26 09:40:21

标签: com vsto ms-office add-in

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

为了缩小问题范围,我创建了两个空白加载项解决方案(Office COM和VSTO加载项)。我在AfterPresentationOpen方法中放置了一个断点,并且每次在名为VSTA_Main的线程上触发断点并抛出此异常。此外,我的try catch块没有捕获此异常。一旦我禁用特定的第三方插件,一切都像魅力一样,断点在主线程上点击,我可以读取计数属性。

我使用的是Windows 7和Office 2010(均为x64)。顺便说一下,我的代码中的“VSTA_Main”线程引发了所有其他PowerPoint事件。我相信所有事件实际上应该在我的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

1 个答案:

答案 0 :(得分:0)

听起来您的某个加载项中存在以下所述的线程问题:

http://www.outlookcode.com/article.aspx?id=71

相关问题