title: Conflict between Office COM add-in and VSTO add-in
body: <p>I have created a simple Office Com add-in which is used among other PowerPoint add-ins on my company computers. Every time PowerPoint starts an AccessViolationException occurs as soon as I am accessing the windows count property in AfterPresentationOpen event (please see code below).</p>
  
  <p>In order to narrow down the issue I created two blank add-in solution (Office COM and VSTO add-in). I placed a breakpoint in AfterPresentationOpen method and every time the breakpoint is hit on a thread called VSTA_Main and throws this exception. Furthermore my try catch block does not catch this exception. As soon as I disable a specific third party addin everything works like a charm and the breakpoint is hit on the Main thread and I can read the count property.</p>
  
  <p>I am using Windows 7 and Office 2010 (both are x64). Btw all other PowerPoint events are raised on the "VSTA_Main" thread in my code. I believe all events should actually be raised on my appdomain thread instead.</p>
  
  <p>Does anyone know how I can handle this error and avoid any conflicts with this add-in?</p>
  
  <pre><code>var windows = presentation.Windows; 
  using (new ComObject(windows)) 
  { 
         try 
         {                 
          var count = windows.Count; 
          if (count == 0) 
              return; 
         } 
         catch (AccessViolationException) 
         {                 
         } 
  }
  </code></pre>
  
  <p>Please find below the call stack.</p>
  
  <pre><code>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
  </code></pre>