V
Vinita Batra
Hi,
I am using office automation in windows service,
I have one static object of ms word app that remains available
throughout the webservice.
i create the object when the windows service is started and this
object is destroyed when service is stopped.
my problem is that since winword object is destroyed when service is
stopped, throughout same word object is used. Now on doing word
operations, memory is getting increased.
I m using the following code. Please help me on this.
I m using following code in when i start windows service
private static Microsoft.Office.Interop.Word.ApplicationClass
oWordApp = null;
private static Microsoft.Office.Interop.Word.Document oWordDoc =
null;
oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
oWordDoc = oWordApp.Documents.Add(ref missing, ref missing, ref
missing, ref missing);
// the abobe line is, so that if some body opens word doc by double
click on explorer and then on closing word doc, my winnword.exe does
not get killed.//
then operations for word are performed.
when service is stopped then i close word
if (oWordDoc != null)
{
oWordDoc.Close(ref missing, ref missing, ref
missing);
oWordDoc = null;
}
if (oWordApp != null)
{
oWordApp.Application.Quit(ref missing, ref missing,
ref missing);
oWordApp = null;
}
Regards,
Vinita>>
--
I am using office automation in windows service,
I have one static object of ms word app that remains available
throughout the webservice.
i create the object when the windows service is started and this
object is destroyed when service is stopped.
my problem is that since winword object is destroyed when service is
stopped, throughout same word object is used. Now on doing word
operations, memory is getting increased.
I m using the following code. Please help me on this.
I m using following code in when i start windows service
private static Microsoft.Office.Interop.Word.ApplicationClass
oWordApp = null;
private static Microsoft.Office.Interop.Word.Document oWordDoc =
null;
oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
oWordDoc = oWordApp.Documents.Add(ref missing, ref missing, ref
missing, ref missing);
// the abobe line is, so that if some body opens word doc by double
click on explorer and then on closing word doc, my winnword.exe does
not get killed.//
then operations for word are performed.
when service is stopped then i close word
if (oWordDoc != null)
{
oWordDoc.Close(ref missing, ref missing, ref
missing);
oWordDoc = null;
}
if (oWordApp != null)
{
oWordApp.Application.Quit(ref missing, ref missing,
ref missing);
oWordApp = null;
}
Regards,
Vinita>>
--