I'm getting: exception has been thrown by the target of an invocation

﹥>﹥吖頭↗ 提交于 2019-12-11 03:15:03

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/15327885/im-getting-exception-has-been-thrown-by-the-target-of-an-invocation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!