COM components referenced in asp.net leave SQL connections open

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.
 
G

George

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,266
Messages
2,571,088
Members
48,773
Latest member
Kaybee

Latest Threads

Top