memory increase problem

V

Vinita

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.
 
B

Bob Buckland ?:-\)

Hi Vinita,

You may want to use the link below to also post this in the MS OfficeDev discussion group. Please include there the version of Word
you're working with and if you're using the MS Visual Studio Tools for Office (VSTO).

==========
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>>
--
Please let us know if this has helped,

Bob Buckland ?:)
MS Office System Products MVP

LINKS
A. Specific newsgroup/discussion group mentioned in this message:
news://msnews.microsoft.com/microsoft.public.officedev
or via browser:
http://microsoft.com/communities/newsgroups/en-us/?dg=microsoft.public.officedev

B. MS Office Community discussion/newsgroups via Web Browser
http://microsoft.com/office/community/en-us/default.mspx
or
Microsoft hosted newsgroups via Outlook Express/newsreader
news://msnews.microsoft.com
 

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