c# - 我得到 : exception has been thrown by the target of an invocation

标签 c# iis handler

当我尝试打开我的页面时出现异常:

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/

相关文章:

c# - 如何在 Microsoft Azure 中的同一解决方案中引用项目

c# - 我无法在 ODBC(RDO) 中找到数据源以使用 VS2015 添加到 Crystal 报告 Mysql 中

c# - 类库找不到 MembershipUser

php - Laravel .htaccess 重写规则转换为 IIS

java - 使用回调后执行到 UI 主线程的方法创建 Runnable 类

java - Eclipse e4 - 添加结束部分处理程序

java - 一般为: why use click-handlers instead of subclassing?

c# - 在 C# 中解析 XML

.net - ASP.NET 代理应用程序

IIS应用程序初始化模块和内存管理