Asp – .NET force COM objects release

asp.netcomnet

I have an ASP.NET 2.0 application under IIS that has the functionnality of
exporting some data to a software called HFM (Oracle Hyperion Financial Management).
To perform that export, the .net application uses an API based on COM objects provided by the HFM client (the client is installed on the same machine that the server, etc.)

My problem is that the API provides a method to connect to the HFM server but not to disconnect.
The documentation says that to disconnect, the application must call the method Marshal.ReleaseComObject() on each COM object created.
But there are a lot of complex actions performed and I am not able to release all created object.
So my application doesn't disconnect.

I've noticed that when I replace the ASP.NET application dll files (which seems to reinit the objects instanciated by .NET), the application automatically disconnects.

I tried several times to call :

GC.Collect();
GC.WaitForPendingFinalizers();

But the problem remains.
I'm looking for a way to be sure that ANY object created, even COM objects are released.
I tried with Marshal.FinalReleaseComObject() but it's not better.

As I put a lock() on that section, there is always at most one user on that part so I can even use hardcore techniques to release the COM objects.

Is there a way to know which object or at least the type of the object that has not been released ?

Thanks for your help.

Best Answer

But there are a lot of complex actions performed and I am not able to release all created object.

There's your problem.

You're looking for an easy way out. But you're working with COM. The only easy way out you get is when your process/appdomain is shut down.