title: How do I avoid RPC_E_CALL_REJECTED exceptions when performing PowerPoint automation?
body: <p>When my code tries to create a new instance of <code>Microsoft.Office.Interop.PowerPoint.Application</code>, I sometimes get the following exception:</p>
  
  <pre><code>System.Runtime.InteropServices.COMException (0x80010001): Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)).
     at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
     at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
     at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
     at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean&amp; canBeCached, RuntimeMethodHandleInternal&amp; ctor, Boolean&amp; bNeedSecurityCheck)
     at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
     at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
     at System.Activator.CreateInstance(Type type, Boolean nonPublic)
  </code></pre>
  
  <p>I say sometimes because it doesn't happen consistently even given the same input.  Furthermore, it also occurs (with the same lack of consistency) in other parts of my code where I also interact with the PowerPoint automation API.</p>
  
  <p>I have tried out <a href="http://msdn.microsoft.com/en-us/library/ms228772%28v=vs.100%29.aspx" rel="noreferrer">this</a> solution from MSDN itself which seems to be the most recommended solution out there.  However, it doesn't seem to have any impact as I still observe the same behavior.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Does the MSDN solution work for PowerPoint automation?</li>
  <li>How can I verify whether I have correctly applied it to my code?</li>
  <li>Does anyone have an alternative solution?</li>
  </ol>
  
  <p>I am using C#, .NET 4, and PowerPoint 2007.</p>