[ERROR] SNINativeMethodWrapper.SNIPacketGetConnection <System.Threading.ThreadAbortException> Thread was being aborted.
今天幫同事Debug時,發現程式跑很久,然後就產生「SNINativeMethodWrapper.SNIPacketGetConnection <System.Threading.ThreadAbortException> Thread was being aborted.」的錯誤!
詳細的錯誤如下,
at SNINativeMethodWrapper.SNIPacketGetConnection(IntPtr packet)
at System.Data.SqlClient.TdsParserStateObject.ProcessSniPacket(IntPtr packet, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
at System.Data.SqlClient.TdsParserStateObject.ReadByte()
at System.Data.SqlClient.TdsParserStateObject.ReadUInt16()
at System.Data.SqlClient.TdsParser.ProcessDone(SqlCommand cmd, SqlDataReader reader, RunBehavior& run, TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
httpWtach錄到的錯誤為「[HttpException (0x80004005): Request timed out.] 」。
判斷應該是超出了executionTimeout的時間,預設.net 2.0預設timeout為110秒,跟錄到的135秒差不多!
所以就在web.config中的<system.web>下加入了
<httpRuntime executionTimeout = "360" />
再重新執行一次就可以了!
這裡要注意的是,設定executionTimeout屬性,.net 1.1使用的格式是"HH:MM:SS",.net 3.5 之後就直接用 秒數 了哦!
您可能要檢查一下雖然IIS那是設定 .net 2.0,但有可能它使用的 framework 是 3.5 的哦!
感謝同事 貝蒂 的討論。
Hi,
亂馬客Blog已移到了 「亂馬客 : Re:從零開始的軟體開發生活」
請大家繼續支持 ^_^