I just lived through this.
If there's any possible way to get around using ASP.NET to automate office,
then do it, Run screaming into the hells and never look back, chilld!!
Here's the thing. If you scour the microsoft site, they strongly recomment
that you don't do this. The COM objects dont end up geting released, even
if you tell them to through Marshall.ReleaseComObject. What happens is that
for every "thing" that you reference, you have to distroy the reference
explicitly with ReleaseComObject. For example, if you were using an excel
spreadsheet and all you wanted to do was open a workbook and change the
value of a single cell, you would have to create explicit variables for the
(here we go) Application, WordbooksCollection, ActiveSheet, ActiveSheetRange
and the Cell you're referring to. If you want to refer to 20 different
cells, then you have to create a reference to each cell explicitly and then
explicitly call ReleaseCOMObject on every one. Forget a single cell and
you're toast.
In the case of PowerPoint, you'd have to create a seperate variable for
every shape. presentation, slide and textbox you use. You can't reassign a
variable because when the reference is changed, you can't call
ReleaseCOMObject on it.
I ended up haveing to use Word and Excel for a project, under duress. As a
result, we had to resolve the issue with the following approach.
Only one instance of the application word can exist at any time
Only one instance of the application excel can exist at any time
Don't directly Create an instance of the applicationClass. Delegate that to
a worker function (e.g. GetWordInstance)
GetWordInstance performs the following actions:
Execute System.Diagnostics.Process.GetProcessesByName("MSW ORD")
If no processes exist, then create a new Word.ApplicationClass and return
it
If a process does exist, wait 1/5 second and try again.
If a total of 20 seconds pass without being able to create a word
application then throw an exception
When you are finished with the Word Application, you have to call a
releaseWordInstance function which does the following
Execute System.Diagnostics.Process.GetProcessesByName("MSW ORD")
For each Process taht is returned, kill it!
I hate that we had to do this, but it was the only soution that we could
come up with.
"Amitava Sengupta" <it********@rediffmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Is there any issue in using COM component in web applications. The
problem I'm facing are
1. Though the dll is using non-static member variables which are being
instantiated on each call, Whenever I'm calling the (.aspx) pages using
the dll more than once simultaneously, both results in garbage. When
called once it is perfect in result.
2. The memory is not being released in web application of the dll even
after finishing properly with result. Again it is perfect when using in
non-web application (say VB exe application). Actually, the dll is using
PowerPoint classes and opening a ppt file. And the PowerPoint is
releasing memory long after.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!