Tags: 0x800706be, aim, aspx, automate, call, created, document, failed, microsoft, mind, net, office, procedure, remote, systemruntimeinteropservicescomexception, webservice, word

System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed

On .Net » .Net Technology

7,282 words with 0 Comments; publish: Sun, 06 Jan 2008 04:31:00 GMT; (10062.01, « »)

Hi,

I have created a WebService that is created with the aim in mind to automate Microsoft Office 2003 word document. WebService works fine most of the time and do the required job means placing data in the word document that is placed some where on FileServer.

But i do not know what happens behind the scene that some times WebService throws the following Exception and then stops working further.

System.Runtime.InteropServices.COMException (0x800706BE): The remote procedure call failed.

and I have observed that it happens when Webservice is trying to save the document.

One more problem that appears after this is that WinWord.exe remains open when I check in the Task Manager.

Here below is just a abstract of the logic that my webService is using.I have made the area about which I have doubt bold.

PublicFunction ModifyDocumentFields(ByVal strParamFilePathAsString,ByVal strValueNeedtoPlaceInDocument as String)AsInteger

objWordApplication =New word.Application

objWordDocument =New word.Document

TryDim objReadOnlyFlagAsObject =False'Word Instance Settings

objWordApplication.Visible =False

objWordDocument = objWordApplication.Documents.Open(strParamFilePath, missing, objReadOnlyFlag, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)

objWordDocRange = objWordDocument.Range(missing, missing)

objWordApplication.DisplayAlerts = word.WdAlertLevel.wdAlertsNone

'To Improve Application Performance

objWordApplication.ScreenUpdating =False'To Improve Application Performance. Don't update the screen to show the effect of changesCatch exAs Exception

IntResult = 0

Try

objWordDocument.Close(word.WdSaveOptions.wdDoNotSaveChanges, missing, missing)

objWordApplication.Quit(missing, missing, missing)

Catch Ex1As Exception

'Log Errors and Exceptions functionality herehere

EndTry

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocRange)

IfNot IsNothing(objWordDocTable)Then

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocTable)

EndIf

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocument)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordApplication)

System.GC.Collect()

Return IntResult

EndTryTry

objWordDocument.Save() 'At the save of Document, I think Exception occurs. and later leaves the Server with winWord.exe

objWordDocument.Close(missing, missing, missing)

objWordApplication.Quit(missing, missing, missing)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocRange) IfNot IsNothing(objWordDocTable)Then

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocTable)

EndIf

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocument)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordApplication)

IntResult = 1

objWordDocument =

Nothing

objWordApplication =Nothing

System.GC.Collect()

Return IntResult

Catch exAs Exception

'Log Errors and Exceptions here

IntResult = 0

objWordDocument.Close(word.WdSaveOptions.wdDoNotSaveChanges, missing, missing)

objWordApplication.Quit(missing, missing, missing)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocRange)

IfNot IsNothing(objWordDocTable)Then

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocTable)

EndIf

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordDocument)

System.Runtime.InteropServices.Marshal.ReleaseComObject(objWordApplication)

System.GC.Collect()

Return IntResult

EndTry

EndFunction

All Comments

Leave a comment...

  • 0 Comments