关于System.Runtime.InteropServices.COMException (0x80070006): 句柄无效的问题

    今天发生一个意外情况。情况是这样的:

    本地开发环境下,运行网站,在某个画面里进行数据检索,刚开始没有问题,在测试分页按钮“末页”时,出现状况,无法检索数据,并且之后查看其他页面时,只要与数据库有关的操作,都无法正常操作。

    之后查看了日志,显示以下的错误信息:

    System.Runtime.InteropServices.COMException (0x80070006): 句柄无效。 (异常来自 HRESULT:0x80070006 (E_HANDLE))
   在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   在 System.Data.SqlClient.SqlConnection.Open()

   多次出现以上异常信息后,又出现以下信息:

    System.UnauthorizedAccessException: 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))
   在 System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   在 System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   在 System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   在 System.Data.SqlClient.SqlConnection.Open()

    之前的开发测试过程中从未出现,所以认为两个异常应该是同一个原因造成的,之后通过GOOGLE,找到一MSDN论坛帖,贴主和我有类似的情况,并且最后表示问题已经解决。具体内容:

    问题:

   Hi,

    I got the following errors in our C# Windows application:

    1. Type : System.Runtime.InteropServices.COMException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    Message : The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
    Source : mscorlib

    Help link :

    ErrorCode : -2147024890

    Data : System.Collections.ListDictionaryInternal

    TargetSite : Void ThrowExceptionForHRInternal(Int32, IntPtr)

    Stack Trace :    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

       at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)

       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)

       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory     connectionFactory)

       at System.Data.SqlClient.SqlConnection.Open()

       at Microsoft.Practices.EnterpriseLibrary.Data.Database.OpenConnection()

       at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command)


    2. Type : System.UnauthorizedAccessException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    Message : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    3. Type : System.Threading.SemaphoreFullException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    Message : Adding the given count to the semaphore would cause it to exceed its maximum count.

    Note:

    1. We are using Microsoft Enterprise Library 2006 Data Access & Exception Application Blocks in our application.
    2. We are using a method save each action(Journal Entry) of the application into a database which can be as frequent as fraction of a second

    An early solution to this will be a helpful one.

    解决方案:

    Hi All,

    I got the solution for this.

  Include 'Min Pool Size =1'  in the connection string.


    参照:http://social.msdn.microsoft.com/Forums/vstudio/zh-CN/bca55280-e49b-4e5c-8c39-3933ed7f3a54/the-handle-is-invalid-exception-from-hresult-0x80070006-ehandle

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值