Started getting "InvalidOperationException was unhandled" since upgrading to .Net 2.0

B

Ben Fidge

Since upgrading my project to .Net 2.0 i've been getting the following error
on occassion:

"InvalidOperationException was unhandled"

followed by

"Internal .Net Framework Data Provider error 1."

The error happens when I call SqlConnection.Close(), but not all the time.
The error can happen over an hour after any activity in my ASP.NET 2.0
application.

Here's some info:

- I have a timer that is started in Application_Start and every hour
performs some house-cleaning duties for my app
- I first check to see if SqlConnection.State == ConnectionState.Open before
I call Close(), but this doesn't prevent the error.
- This has only been happening since upgrading my project to VS 2005 from
VS.NET 2003
- On our live server, this is causing a JIT debugging dialog to pop-up
asking if I want to debug. AS the source isn't available on the server, this
has limited use.
- I'm using Sql Server 2005

Anyone know why this is happening?

Thanks

Ben
 
V

Val Mazur \(MVP\)

Ben,

It would be nice to see what kind of information is in a stack of the
exception. If you get it on Close, then it is quite possible that connection
already closed. Checking of the State property is not a reliable way to
check status of the connection because this property does not reflect actual
*live* state of the connection, but the state of the connection when it was
Open method called. If your application opened connection successfully, then
State property will show status connected even if connection was broken
later on
 
B

Ben Fidge

Hi Val,

I'll try and grab the call-stack for you, but remember that it didn't reveal
too much anyway.

On your advice I've removed the checking of ConnectionState and have
replaced it with a try..catch block. Can you suggest a better way?

Thanks for your help,

Ben
 

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

Top