We are using an out-of-process COM object--created with HttpContext.Current.Server.CreateObject("Class.obj ect")--in an VB/ASP.NET 1.x application.
The COM object releases a-ok when we use System.Runtime.InteropServices.Marshal.ReleaseComO bject to release the object. We are running into trouble when our users don't hit the logout button on our web-based application.
Stuffing the ReleaseComObject call from above in Session_End() doesn't seem to do the trick; we get a system.unauthorizedaccessexception permission denied error. I'm guessing this is because the process has already been released in some way because the session has timed out.
We create the com object in a class that we instantiate in our application, so I thought we could use the class destructor. Stuffing the releaseComObject call from above in Protected Overrides Sub Finalize() doesn't work either; this sub doesn't seem to get triggered at all on aspx session timeout.
Finally, I tried a GC.collect in Session_End(), but this didn't seem to do anything either. At least it didn't throw an error.
In all these cases, I look in the task manager and still see the out-of-process com object running after session timeout, and the aspnet_wp.exe is growing on our servers over time, so it seems like some garbage collection is not occuring.
My thoughts were:
1. Is there a way to do all proper garbage collection on session_end?
2. If not, is there a way to create the object at the application, rather than session level (but not in global.asax because they are on-demand during the session), so that I can deal with garbage collection extra-session?
Any thoughts or suggestions would be appreciated. Thanks!
Rich