当我尝试打开我的页面时出现异常:
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()
在页面中出现错误:
Message: Exception has been thrown by the target of an invocation.
有什么想法吗?
提前致谢
最佳答案
页面中的错误听起来无关紧要,应该通过捕获和记录它来进行调查。如果您最终捕获了 TargetInvocationException
,那么您可以通过 .InnerException
获取实际异常。
关于另一个问题:什么是 DsNet?那是你的代码吗?或者你正在使用的图书馆?无论哪种方式,听起来它在终结器中都有一个错误(在终结器中接触托管对象是一个真的坏主意)。我希望您可以通过在 DsNet 周围使用 using
来减少这种脾气暴躁,这样它就可以在常规代码中处理,而不是finalized 在 GC 扫描中。 DsNet.CUIHandler
我在 google 中得到的唯一“命中”是这个问题 - 所以我猜测那是你的代码。如果是这样:不要在终结器中触及其他托管对象。
关于c# - 我得到 : exception has been thrown by the target of an invocation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15327885/