COM component in web applications

  • Thread starter Thread starter Amitava Sengupta
  • Start date Start date
A

Amitava Sengupta

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.
 
Amitava,

Yes, there is. You have to set the ASPCompat attribute on your pages
that use the COM component to true. This takes the thread that the page is
processed on, and creates a COM apartment for it. This is much less
performant than a solutuion without COM interop in it.

When you are using your powerpoint object, you have to be sure to call
the static ReleaseComObject method on the Marshal class, passing the COM
object you are using. You have to be careful when using the COM object,
because using properties that expose objects will leave references lying
around. For example, in Excel, if you did this in .NET (this is
psuedo-code):

Excel.Application app = new Excel.Application();
app.ActiveWorkbook.Worksheets.Cells(1, 1).Value = 4;

In the above example, there are five COM objects that are being used,
but never released. In this case, you would have to make sure that you
assign each property retrieval to a variable, and then pass it to the static
ReleaseComObject to make sure that it is released. This is especially true
for Office applications, since each object seems to have a reference to the
main Application object, and if one of those objects hangs around, the
Application instance hangs around, even if Quit is called on it.

Hope this helps.
 
Back
Top