Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT) when running a PowerPoint VBA Macro from C# Code
-
Wednesday, May 30, 2012 11:47 AM
Hi,
I have stuck into this weird problem and need urgent help! Before I discuss this issue I want to mention that this is only happening in Windows 2003 server (SP2) but the same code runs fine in Windows XP (SP3). I have also browsed a lot in Google and the related forums but didn't find any useful solution for my case.
Now, here is the detail:
For our client we are building an application which will automate some tasks which include:
1. Opening a PowerPoint slide from a SharePoint document library
2. Run some VBA Macros on it
3. At the end save the slide in the same SP Doc library and close PowerPoint application.
The VBA Macros are being consolidated into an PowerPoint add-in file, which is deployed in the server where my C# application will run.
Now, surprisingly some Macros are running fine but in particualr one macro I am getting the said error.
Here is how I have initiated the PowerPoint in my C# code
using PowerPoint = Microsoft.Office.Interop.PowerPoint; PowerPoint.Application oPP = new PowerPoint.ApplicationClass(); oPP.DisplayAlerts = Microsoft.Office.Interop.PowerPoint.PpAlertLevel.ppAlertsNone; oPP.Visible = MsoTriState.msoTrue; PowerPoint.Presentations oPresSet = oPP.Presentations; PowerPoint._Presentation _activePres = oPresSet.Open("My SharePoint File Location", MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoTrue);
Now Calling the macro
object _retobj = RunMacro(oPP, new Object[] { "MyMacroRunning", true}); object _retobj1 = RunMacro(oPP, new Object[] { "MyMacroNotRunning"});Here is my RunMacro Method:
public object RunMacro(object oApp, object[] oRunArgs) { try { return oApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, oApp, oRunArgs); } catch (Exception _exp) { //Log Exception } return null; }
As I mentioned before, some Macros are running fine and I am able to get the return value from them. But, one particular macro is not running.
Here is the definition of the Macro which is running:
Function MyMacroRunning(params As Boolean) As Boolean On Error GoTo HANDLER 'Some Code Exit Function HANDLER: 'Error Handling End Function
and here is the one which is not running. I have placed tracing inside this one and found that the code is not even reaching inside it, which is very weird.
Function MyMacroNotRunning(Optional control As IRibbonControl) As Boolean On Error GoTo HANDLER 'Some Code Exit Function HANDLER: 'Error Handling End Functionand following is the Error I got:
Exception classes:
System.Reflection.TargetInvocationException
System.Runtime.InteropServices.COMException
Exception messages:
Exception has been thrown by the target of an invocation.
The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
Stack Traces:
--- Exception Stack ---
Target Site: System.Object InvokeDispMethod(System.String, System.Reflection.BindingFlags, System.Object, System.Object[], Boolean[], Int32, System.String[])
Stack Trace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)Any help is appreciated.
Thanks,
Uday
- Moved by Cindy Meister MVPMVP, Moderator Wednesday, July 04, 2012 8:05 AM not using VSTO technology (From:Visual Studio Tools for Office)
All Replies
-
Saturday, June 02, 2012 6:48 AM
Hi,
Some updates,
As indicated above, the error was coming while calling the macro with no argument. So I have created another macro with dummy argument and from that one called the original macro (MyMacroNotRunning). But, still the error is coming!
Surprisingly, for some slides the error is permanent (i.e. the program is failing every time) but for few others the program is getting successful if tried more than once (i.e. even if they are getting failed on the first few runs but eventually they are getting successful).
Any idea how to solve/ bypass this error? Any Windows 2003 patches I need to install?
Thanks in advance.
Uday
-
Monday, June 04, 2012 11:12 PM
Hi,
Could you upload the slide (presentation) for which issue occurs to SkyDrive and share the link.
Are you automating Office at server side (KB 257757)?
thanks,
Shiv Khare
-
Friday, June 22, 2012 1:25 PM
Hi Shiv,
Thanks for your reply. Yes I am automating at server side (Windows 2003 SP2) and I am aware that MS does not support this :(
Anyway, as I stated before, the error is not coming at any particular slide. It is random. i.e. if the error appears in a certain slide then it can happen that the program will run successfully on the next try. I have noticed that there are lots of DW20.EXE processes generated after running the process on near about 100 slides. Any idea?
Thanks,
Uday

