COM components referenced in asp.net leave SQL connections open

  • Thread starter Thread starter ben
  • Start date Start date
B

ben

I am having problems with old COM components that I must use in my
ASP.NET project leavings connections open in the SQL server "Process
Info" with "AWAITING COMMAND".

After some testing I have determined that .NET is not correctly
calling the Class_Terminate in the old COM componet which would close
the connection.

I have tested this with my own API and found that I must expose a
method that allows me to manually clos the SQL connection, so just
before I set the object to nothing I call the .CloseDBConn() - this
works.

The problems is that the APIs I am using are written by third-party
software vendors so I cannot modify them.

I have read that the Garbage Collector is supposed to get rid of these
connections but it doesn't appear to. With every refresh of the
browser so another connection (or two) is born, hundreds will appear
and never disappear.

Hope someone can shed some light on this.
 
The .NET is not releasing COM object until garbage collector collects the wrapper for COM object.

And you never know when this is going to happen.
So you should do exactly the same thing as you do with database connection, file object, ....

Implicitly release it when you need it to be released

Here is how
System.Runtime.InteropServices.Marshal.ReleaseComObject (objMyComObject);



George
My Site - Body Jewelry
I am having problems with old COM components that I must use in my
ASP.NET project leavings connections open in the SQL server "Process
Info" with "AWAITING COMMAND".

After some testing I have determined that .NET is not correctly
calling the Class_Terminate in the old COM componet which would close
the connection.

I have tested this with my own API and found that I must expose a
method that allows me to manually clos the SQL connection, so just
before I set the object to nothing I call the .CloseDBConn() - this
works.

The problems is that the APIs I am using are written by third-party
software vendors so I cannot modify them.

I have read that the Garbage Collector is supposed to get rid of these
connections but it doesn't appear to. With every refresh of the
browser so another connection (or two) is born, hundreds will appear
and never disappear.

Hope someone can shed some light on this.
 
Back
Top