难以捉摸的随机发生的异常 [英] Elusive randomly occuring exceptions

查看:62
本文介绍了难以捉摸的随机发生的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能不是正确的新闻组,但这只是我读过的那个

而且有很多聪明的人活着。在这里。

如果您认为这应该发布在

另一个新闻组中,请不要责备我。


我正在研究的web应用程序(似乎是)随机地打开数据库连接时会抛出异常。并不总是在

的同一个地方。并不总是相同的SqlConnection对象。并不总是

同样的东西。该应用程序可以正常运行数小时或者它可以在最后一个请求的几个请求中崩溃。

这是抛出的最常见的异常:


[COMException(0x80070006):句柄无效。 (例外来自

HRESULT:0x80070006(E_HANDLE))]


System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32

errorCode,IntPtr errorInfo)+ 0

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32

errorCode)+34

系统。 Data.ProviderBase.DbConnectionPool.GetConnect ction(DbConnection

owningObject)+636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection

owningConnection)82


System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(的DbConnection

outerConnection,DbConnectionFactory connectionFactory的)105

System.Data.SqlClient.SqlConnection.Open()+111

System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,

DataTable [ ] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand命令,CommandBehavior行为)+121

Sy stem.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand command,

CommandBehavior behavior)+137

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86


什么句柄????

有时,我得到一个相反,SemephoreFullException:


[SemaphoreFullException:将给定的计数添加到信号量将

导致它超过其最大计数。]

System.Threading.Semaphore.Release(Int32 releaseCount)+1853063

System.Data.ProviderBase.DbConnectionPool.PutNewOb ject(DbConnectionInternal

obj)+54


System.Data.ProviderBase.DbConnectionPool.Deactiva teObject(DbConnectionInternal

obj)+228


系统。 Data.ProviderBase.DbConnectionPool.PutObjec t(DbConnectionInternal

obj,Object owningObject)+265


System.Data.ProviderBase.DbConnectionInternal.Clos eConnection(DbConnection

owningObject,DbConnectionFactory connectionFactory)+97

System.Data.SqlClient.SqlConnection.Close()+ 117

System.Data .Common.DbDataAdapter.QuietClose(IDbCon nection

连接,ConnectionState originalState)+13

System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,

DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand command,CommandBehavior behavior)+285

System.Data.Common.DbDataAdapter。填充(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,
CommandBehavior行为)+137

System.Data。 Common.DbDataAdapter.Fill(DataSet dataSet)+86

或者有时我得到:


[SqlException(0x80131904):发生传输级别错误

将请求发送到服务器。 (提供者:TCP提供者,错误:0 -

尝试对非套接字的操作进行操作。)]

System.Data.SqlClient.SqlConnection.OnError( SqlExc eption异常,

Boolean breakConnection)+857370

System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException

exception,Boolean breakConnection) +734982

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject

stateObj)+188

System.Data。 SqlClient.TdsParserStateObject.ThrowEx ceptionAndWarning()

+13

System.Data.SqlClient.TdsParserStateObject.WriteSn我()638049

系统。 Data.SqlClient.TdsParserStateObject.WritePa cket(Byte

flushMode)+265

System.Data.SqlClient.TdsParserStateObject.Execute Flush()+51

System.Data.SqlClient.TdsParser.TdsExecuteRPC(_Sql RPC [] rpcArray,

Int32 timeout,Boolean inSchema,SqlNotificationRequest

否tificationRequest,TdsParserStateObject stateObj)+3977

System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior

cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean

async)+886

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior

cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String

方法,DbAsyncResult结果)+132

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior

cmdBehavior,RunBehavior runBehavior,Boolean returnStream,String

方法)+32

System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior

行为,字符串方法)+122

系统。 Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior

行为)+12

System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader (CommandBehavior

行为)+7

System.Data.Comm on.DbDataAdapter.FillInternal(数据集数据集,

DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand命令,CommandBehavior行为)+141

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,

CommandBehavior行为) +13 $

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86


我得到任何这些例外后,任何进一步的请求

打开连接结果IIS请求登录凭据 - 无

哪个工作(包括管理员)和重新开始:


[UnauthorizedAccessException:访问被拒绝。 (例外来自

HRESULT:0x80070005(E_ACCESSDENIED))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32

errorCode,IntPtr errorInfo)+ 0

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32

errorCode)+34

系统。 Data.ProviderBase.DbConnectionPool.GetConnect ction(DbConnection

owningObject)+636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection

owningConnection)82


System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(的DbConnection

outerConnection,DbConnectionFactory connectionFactory的)105

System.Data.SqlClient.SqlConnection.Open()+111

System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,

DataTable [ ] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand命令,CommandBehavior行为)+121

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand command,

CommandBehavior behavior)+137

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86

这对我来说比无效句柄异常更不合理。

连接使用SQL登录,而不是Windows身份验证/可信连接。

为什么在任何第一个例外之后登录无效?为什么

IIS提示输入Windows凭据?


这种情况​​发生在XP / IIS5开发框和2003 / IIS6上

生产箱。在我测试的时候,应用程序在

生产框上有自己的应用程序池。


IIS进程(IIS5上的aspnet) ,IIS3上的w3wp)最终会崩溃,但不会立即崩溃。让流程崩溃或手动结束流程或回收应用程序池或重新启动

Web服务将清除问题,并且对于未知的

时间量(可能是下一个请求,可能是第二天)。


我不知道该怎么做。我不知道如何解决这个问题。天

谷歌搜索和搜索论坛没有帮助我。


请帮忙!

This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don''t berate me if you think this should have been posted in
another newsgroup.

The web application I''m currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:

[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

What handle????
Sometimes, I get a SemephoreFullException instead:

[SemaphoreFullException: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threading.Semaphore.Release(Int32 releaseCount) +1853063

System.Data.ProviderBase.DbConnectionPool.PutNewOb ject(DbConnectionInternal
obj) +54

System.Data.ProviderBase.DbConnectionPool.Deactiva teObject(DbConnectionInternal
obj) +228

System.Data.ProviderBase.DbConnectionPool.PutObjec t(DbConnectionInternal
obj, Object owningObject) +265

System.Data.ProviderBase.DbConnectionInternal.Clos eConnection(DbConnection
owningObject, DbConnectionFactory connectionFactory) +97
System.Data.SqlClient.SqlConnection.Close() +117
System.Data.Common.DbDataAdapter.QuietClose(IDbCon nection
connection, ConnectionState originalState) +13
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
Or sometimes I get:

[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) +734982

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParserStateObject.ThrowEx ceptionAndWarning()
+13
System.Data.SqlClient.TdsParserStateObject.WriteSn i() +638049
System.Data.SqlClient.TdsParserStateObject.WritePa cket(Byte
flushMode) +265
System.Data.SqlClient.TdsParserStateObject.Execute Flush() +51
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_Sql RPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj) +3977
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior
behavior) +12

System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader(CommandBehavior
behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:

[UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?

This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it''s own application pool on the
production box for now while I''m testing.

The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).

I don''t know what to do. I don''t know how to troubleshoot this. Days
of googling and searching forums has not helped me.

Please help!

推荐答案

Jeff,

这看起来像某种连接池错误,连接池是基于COM +引擎盖的
。你能发布一些示例代码来说明你的SqlConnections是如何打开和关闭的吗?所有连接的连接字符串

是否相同?

彼得


-

Co -founder,Eggheadcafe.com开发者门户网站:
http://www.eggheadcafe.com

UnBlog:
http://petesbloggerama.blogspot。 com


" Jeff Shepler"写道:
Jeff,
This looks like some sort of Connection Pool error, Connection Pooling is
based on COM+ "under the hood". Can you post some sample code illustrating
how your SqlConnections are being opened and closed? Is the connection string
the same for all connections?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Jeff Shepler" wrote:

这可能不是正确的新闻组,但这只是我读过的

而且有很多聪明的人活着在这里。

如果您认为这应该发布在

另一个新闻组中,请不要责备我。


我正在研究的web应用程序(似乎是)随机地打开数据库连接时会抛出异常。并不总是在

的同一个地方。并不总是相同的SqlConnection对象。并不总是

同样的东西。该应用程序可以正常运行数小时或者它可以在最后一个请求的几个请求中崩溃。


这是抛出的最常见的异常:


[COMException(0x80070006):句柄无效。 (例外来自

HRESULT:0x80070006(E_HANDLE))]


System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32

errorCode,IntPtr errorInfo)+ 0

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32

errorCode)+34

系统。 Data.ProviderBase.DbConnectionPool.GetConnect ction(DbConnection

owningObject)+636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection

owningConnection)82


System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(的DbConnection

outerConnection,DbConnectionFactory connectionFactory的)105

System.Data.SqlClient.SqlConnection.Open()+111

System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,

DataTable [ ] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand命令,CommandBehavior行为)+121

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand command,

CommandBehavior behavior)+137

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86


什么句柄????


有时,我会得到一个SemephoreFullException:


[SemaphoreFullException:将给定的计数添加到信号量中

会导致它超过其最大计数。 ]

System.Threading.Semaphore.Release(Int32 releaseCount)+1853063


System.Data.ProviderBase.DbConnectionPool.PutNewOb ject(DbConnectionInternal

obj)+54

System.Data.ProviderBase.DbConnectionPool.Deactiva teObject(DbConnectionInternal

obj)+228


System.Data.ProviderBase.DbConnectionPool.PutObjec t(DbConnectionInternal

obj,Object owningObject)+265

System.Data.ProviderBase .DbConnect ionInternal.Clos eConnection(DbConnection

owningObject,DbConnectionFactory connectionFactory)+97

System.Data.SqlClient.SqlConnection.Close()+ 117

System.Data.Common.DbDataAdapter.QuietClose(IDbCon nection

connection,ConnectionState originalState)+13

System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,

DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand command,CommandBehavior behavior)+285

System.Data.Common .DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,

CommandBehavior行为)+137

系统.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86


或者有时我得到:


[SqlException(0x80131904):A

将请求发送到服务器时发生传输级错误。 (提供者:TCP提供者,错误:0 -

尝试对非套接字的操作进行操作。)]

System.Data.SqlClient.SqlConnection.OnError( SqlExc eption异常,

Boolean breakConnection)+857370

System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException

exception,Boolean breakConnection) +734982

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject

stateObj)+188

System.Data。 SqlClient.TdsParserStateObject.ThrowEx ceptionAndWarning()

+13

System.Data.SqlClient.TdsParserStateObject.WriteSn i()+638049

系统。 Data.SqlClient.TdsParserStateObject.WritePa cket(Byte

flushMode)+265

System.Data.SqlClient.TdsParserStateObject.Execute Flush()+51

System.Data.SqlClient.TdsParser.TdsExecuteRPC(_Sql RPC [] rpcArray,

Int32 timeout,Boolean inSchema,SqlNotificationReq uest

notificationRequest,TdsParserStateObject stateObj)+3977

System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior

cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean

async)+886

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior

cmdBehavior,RunBehavior runBehavior,Boolean returnStream,字符串

方法,DbAsyncResult结果)+132

System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior

cmdBehavior,RunBehavior runBehavior,Boolean returnStream ,String

方法)+32

System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior

behavior,String method)+122

System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior

行为)+12


System.Data.Common.DbCommand .System.Data.IDbComman d.ExecuteReader(CommandBehavior

行为)+7

System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,

DataTable [] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand命令,CommandBehavior行为)+141

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,

CommandBehavior行为)+137

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86


之后我得到任何这些例外,任何进一步的请求尝试

打开连接结果IIS请求登录凭据 - 无

哪个工作(包括管理员)和重新插入:


[UnauthorizedAccessException:访问被拒绝。 (例外来自

HRESULT:0x80070005(E_ACCESSDENIED))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32

errorCode,IntPtr errorInfo)+ 0

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32

errorCode)+34

系统。 Data.ProviderBase.DbConnectionPool.GetConnect ction(DbConnection

owningObject)+636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection

owningConnection)+82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection

outerConnection,DbConnectionFactory connectionFactory)+105 >
System.Data.SqlClient.SqlConnection.Open()+111

System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,

DataTable [ ] datatables,Int32 startRecord,Int32 maxRecords,String

srcTable,IDbCommand command,CommandBehavior behavior)+121

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet,Int32

startRecord,Int32 maxRecords,String srcTable,IDbCommand命令,

CommandBehavior行为)+137

System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)+86


这对我来说比无效句柄异常更不合理。

连接使用SQL登录,而不是Windows身份验证/可信连接。

为什么在任何第一个例外之后,登录无效?为什么

IIS提示输入Windows凭据?


这种情况​​发生在XP / IIS5开发框和2003 / IIS6上

生产箱。在我测试的时候,应用程序在

生产框上有自己的应用程序池。


IIS进程(IIS5上的aspnet) ,IIS3上的w3wp)最终会崩溃,但不会立即崩溃。让流程崩溃或手动结束流程或回收应用程序池或重新启动

Web服务将清除问题,并且对于未知的

时间量(可能是下一个请求,可能是第二天)。


我不知道该怎么做。我不知道如何解决这个问题。天

谷歌搜索和搜索论坛没有帮助我。


请帮助!

This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don''t berate me if you think this should have been posted in
another newsgroup.

The web application I''m currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.
Here is the most common exception thrown:

[COMException (0x80070006): The handle is invalid. (Exception from
HRESULT: 0x80070006 (E_HANDLE))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

What handle????
Sometimes, I get a SemephoreFullException instead:

[SemaphoreFullException: Adding the given count to the semaphore would
cause it to exceed its maximum count.]
System.Threading.Semaphore.Release(Int32 releaseCount) +1853063

System.Data.ProviderBase.DbConnectionPool.PutNewOb ject(DbConnectionInternal
obj) +54

System.Data.ProviderBase.DbConnectionPool.Deactiva teObject(DbConnectionInternal
obj) +228

System.Data.ProviderBase.DbConnectionPool.PutObjec t(DbConnectionInternal
obj, Object owningObject) +265

System.Data.ProviderBase.DbConnectionInternal.Clos eConnection(DbConnection
owningObject, DbConnectionFactory connectionFactory) +97
System.Data.SqlClient.SqlConnection.Close() +117
System.Data.Common.DbDataAdapter.QuietClose(IDbCon nection
connection, ConnectionState originalState) +13
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +285
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
Or sometimes I get:

[SqlException (0x80131904): A transport-level error has occurred when
sending the request to the server. (provider: TCP Provider, error: 0 -
An operation was attempted on something that is not a socket.)]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception,
Boolean breakConnection) +857370
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException
exception, Boolean breakConnection) +734982

System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject
stateObj) +188
System.Data.SqlClient.TdsParserStateObject.ThrowEx ceptionAndWarning()
+13
System.Data.SqlClient.TdsParserStateObject.WriteSn i() +638049
System.Data.SqlClient.TdsParserStateObject.WritePa cket(Byte
flushMode) +265
System.Data.SqlClient.TdsParserStateObject.Execute Flush() +51
System.Data.SqlClient.TdsParser.TdsExecuteRPC(_Sql RPC[] rpcArray,
Int32 timeout, Boolean inSchema, SqlNotificationRequest
notificationRequest, TdsParserStateObject stateObj) +3977
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +886
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteDbDataRead er(CommandBehavior
behavior) +12

System.Data.Common.DbCommand.System.Data.IDbComman d.ExecuteReader(CommandBehavior
behavior) +7
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +141
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86

After I get any of those exceptions, any further requests that attempt
to open the connection results IIS requesting login credentials - none
of which work (including administrator) and resuts in:

[UnauthorizedAccessException: Access is denied. (Exception from
HRESULT: 0x80070005 (E_ACCESSDENIED))]

System.Runtime.InteropServices.Marshal.ThrowExcept ionForHRInternal(Int32
errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32
errorCode) +34
System.Data.ProviderBase.DbConnectionPool.GetConne ction(DbConnection
owningObject) +636

System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection) +82

System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +86
This makes even less sense to me than the Invalid Handle exception.
The connection uses a SQL login, not windows auth/trusted connection.
Why, after any of the first exceptions, is the login not valid? Why is
IIS prompting for windows credentials?

This happens on both an XP/IIS5 develeopment box and a 2003/IIS6
production box. The application has it''s own application pool on the
production box for now while I''m testing.

The IIS processes (aspnet on IIS5, w3wp on IIS6) will eventually
crash, but not immediately. Letting the process crash or manually
ending the process or recycling the application pool or restarting the
web service will clear the problem and all will be fine for an unknown
amount of time (could be the next request, could be the next day).

I don''t know what to do. I don''t know how to troubleshoot this. Days
of googling and searching forums has not helped me.

Please help!


Jeff Shepler写道:
Jeff Shepler wrote:

这可能不是正确的新闻组,但这只是

一个我读过的,有很多聪明的人活着在这里。

如果您认为这应该发布在

另一个新闻组中,请不要责备我。


我正在研究的web应用程序(似乎是)随机地打开数据库连接时会抛出异常。并不总是在

的同一个地方。并不总是相同的SqlConnection对象。并不总是

同样的东西。该应用程序可以正常运行数小时或者它可以在最后一个请求的几个请求中崩溃。
This is probably not the right newsgroup for this, but this is the
only one I read and there are a lot of smart people that "live" here.
Please don''t berate me if you think this should have been posted in
another newsgroup.

The web application I''m currently working on will (seemingly) randomly
throw an exception when opening a database connection. Not always in
the same place. Not always the same SqlConnection object. Not always
the same anything. The application could run fine for hours or it
could crash within a couple of requests of the last one.



< snippedy-doo -dah>


你好Jeff,


听起来你在这里有一些奇怪的heisenbug。您是否在任何地方使用线程

或异步操作?


-

希望这会有所帮助,

Tom Spink

<snippedy-doo-dah>

Hi Jeff,

Sounds like you''ve got some wierd heisenbug here. Are you using threading
or asynchronous operations in your code anywhere?

--
Hope this helps,
Tom Spink


该应用程序池运行的安全上下文是什么,并且是IIS使用

模仿(基于网络用户帐户) - 因为我/相信/游泳池是按照NT身份和连接字符串分割的
(即使不使用

集成安全性)。 />

Marc

Also what security context is the app-pool runing under, and is IIS using
impersonation (based on the web-user account) - as I /believe/ the pool is
split by NT identity as well as connection string (even if not using
integrated security).

Marc


这篇关于难以捉摸的随机发生的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆