2

I´m getting the exception when I try to open my page:

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/6/ROOT/ROXY/es

Process ID: 2972

Exception: System.InvalidOperationException

Message: Handle is not initialized.

StackTrace:
at System.WeakReference.set_Target(Object value)
at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Close()
at DsNet.CUIHandler.CloseConn()
at DsNet.CUIHandler.Finalize()

An in the page I get the error:

Message: Exception has been thrown by the target of an invocation.

Any idea?

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ernesto Rodriguez
  • 257
  • 2
  • 9
  • 26

1 Answers1

7

The bug in the page sounds unrelated, and should be investigated by catching and logging it. If you do end up catching a TargetInvocationException, then you can get the actual exception via the .InnerException.

Re the other issue: what is DsNet? Is that your code? or a library you are using? Either way, it sounds like it has a bug in the finalizer (touching managed objects is a really bad idea in a finalizer). I expect you may be able to make this less grumpy by using using around whetever is DsNet, so that it gets disposed in regular code, rather than finalized in the GC sweep. The only "hit" I'm getting in google for DsNet.CUIHandler is this question - so I'm guessing that is your code. If so: don't touch other managed objects in a finalizer.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • That's the problem, DsNet is a library I am using and I have not access to modify it. Any way to identify the problem? The site was working fine for years – Ernesto Rodriguez Mar 10 '13 at 21:47
  • @ErnestoRodriguez the finalizer (as part of GC) will happen at unpredictable times, so that should ideally be addressed separately; like I say, the best thing I can advise is : make sure you're using `using`, or otherwise disposing the `IDisposable` objects after you're done with them. Other than that: you haven't given much to go on... all I can say is "some kind of coding, configuration or environment issue". That doesn't help much... – Marc Gravell Mar 10 '13 at 21:49