Chr*_*eng 7 c# powerpoint comexception office-interop
当我的代码尝试创建一个新实例时Microsoft.Office.Interop.PowerPoint.Application,我有时会得到以下异常:
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& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& 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)
Run Code Online (Sandbox Code Playgroud)
我有时会说,因为即使给出相同的输入也不会一直发生.此外,在我的代码的其他部分也会发生(同样缺乏一致性),我也与PowerPoint自动化API进行交互.
我已经从MSDN本身尝试了这个解决方案,这似乎是最推荐的解决方案.但是,它似乎没有任何影响,因为我仍然观察到相同的行为.
我的问题是:
我使用的是C#,.NET 4和PowerPoint 2007.
我还没有尝试过,但 Andrew Whitechapel 描述了与 Office 相同的方法,所以我想它应该有效:http://blogs.msdn.com/b/andreww/archive/2008/11/19/implementing-imessagefilter-in- an-office-add-in.aspx
试一试 :)
另一种方法是通过捕获错误并重试来实现某种等待机制(此处也提到)。
| 归档时间: |
|
| 查看次数: |
12697 次 |
| 最近记录: |