Word automation through ASP.NET - Problem with additional winword processes

C

Chris Ericoli

Hi,

I am attempting to convert .doc files into PDF files through word
automation. My code performs as expected, with the unusual side effect of
spawning 2 winword.exe processes when instantiating the
Word.ApplicationClass object. As you will see from the code, I am only
calling one instance, and using the .Quit() method to close the COM object
(in all of the posts i have read concerning this - this appears to be the
problem that people overlook).

--== CODE ==--

Dim _wdApp As Microsoft.Office.Interop.Word.Application

_wdApp = New Microsoft.Office.Interop.Word.ApplicationClass
_wdApp.DisplayAlerts =
Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone

_wdDoc = _wdApp.Documents.Open("c:\test.doc", False, True)

'Printing code ommitted

_wdDoc.Close(False)
_wdApp.Quit(Type.Missing, Type.Missing, Type.Missing)
_wdApp = Nothing


When stepping through the code, I have noticed something very odd. The
debugger steps through the (_wdApp = New Microsoft.Office.Interop.Word etc
etc) two times. When I examine the processes in Task Manager, I notice that
each time the debugger steps through this line of code, a winword.exe
process is spawned. This means that when i call the _wdApp.Quit method,
only one of the processes ends, leaving a second process behind (which I
can't close).

I have tried using
System.Runtime.InteropServices.Marshal.ReleaseComObject(_wdApp) but this is
the same as the Quit method.

I am very confused by this behaviour - and would really appreciate any help
whatsoever. I understand the limitations of running Word on the IIS server,
but I have no choice.

Other info:

VSNET 2003
Office 2003 (Office 11 Object Library)


Cheers

Chris
 
A

Andy Fish

I too am automating word on the server but I have not seen this problem.

The only thing I'm doing differently to you is to use:
new Application()
rather than
new ApplicationClass()

(I can't remember why now, but I did read somewhere that this is the
"better" way of doing it).

It seems very suspicious that the debugger is stopping twice on this line -
it definitely doesn't do that for me. If I were you I would try to borrow
someone else's machine to test on. Maybe you have a corrupt installation of
word or of the interop assemblies.

Andy
 
C

Chris Ericoli

Thanks Andy, I appreciate you taking the time to reply.

I have tried both the Application Interface and the ApplicationClass Class
objects, with both doing the same thing.

You are right that it is highly suspicious that the debugger steps through
the code twice. It looks like it creates a process for New
ApplicationClass, and then a second process when it assigns it to the
_wrdApp variable.

Anyway, I will test it on another machine and see how I go.

Cheers

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top