vb.net – SqlClient调用导致“正在SNINativeMethodWrapper.SNIP
我真的很感激任何建议,无论多么简单或复杂,帮助我解决这个问题.
我有一些生成小报告文件的代码.对于集合中的每个文件,执行存储过程以通过XML阅读器获取数据(它是一个非常大的结果集).当我创造了这一切,并逐步完成它,一切都很好.生成文件,没有错误. 该库通过远程处理调用,并通过IIS托管.当我部署已编译的库并调用它时,它能够生成一些报告,但随后会抛出一个Thread Abort Exception.如果我将调试器附加到asp工作进程,并逐步执行代码,我没有问题. 看到这种失败是非常一致的,我寻找相似之处并发现失败发生在不同的报告上,但似乎发生在大约相同的时间点. 这让我认为这是一个超时设置,调试器重写,我做了一些粗略的整个过程时间(不是单一的失败代码),它似乎在大约200秒后失败. web.config executionTimeout设置为600分钟(足够高).此服务器应用程序还有其他部分需要COM事务(2分钟超时),但这不是其中之一.我不知道它可能达到的超时时间(大约200秒大关). SQL Connection超时默认保留(连接成功打开),命令超时为300秒(执行命令只需12-15). >我可能缺少任何其他超时吗? 我运行了SQL分析器,它显示结果正确返回(所有语句和RPC完成 – 没有错误).通过SSMS执行代码可提供完美的结果. 使用反射器,我钻进了SNINativeMethodWrapper,它是非托管代码的包装器,我无法看到它试图实际做什么.我只能假设(可能错误地)代码已经从SQL服务器接收到TDS,并且包装器试图获得与数据包关联的连接,但它不能. >有谁知道这个包装器应该做什么? 我尝试使用不同的方法(ExecScalar,DataAdapter),但它们都在内部使用ExecuteReader. 我尝试禁用连接池并强制客户端使用与服务器相同的数据包大小. >有没有人对是什么原因产生任何想法,或者我可以做些什么来隔离并尝试纠正问题? 这是生成异常的调用代码. Private Function GetDataAsXmlDoc(ByVal cmd As SqlClient.SqlCommand) As XmlDocument Dim _xmlDoc As XmlDocument Using _connection As New SqlClient.SqlConnection(GetConnectionString()) Logging.DebugEvent.Raise(Me.GetType.Namespace,Reflection.MethodBase.GetCurrentMethod().Name,_ "No cached data found or used. Getting data for report from the database using SQL connection.") Dim _xmlReader As XmlReader 'DataAdapter,ExecuteScalar,ExecuteXmlReader all use ExecuteReader internally and suffer the same problem.' 'If you dont believe me,reflect it or look at one of the blowed up stack traces. ' '_connection.ConnectionString += ";Pooling=false;"' 'This has no effect on the ThreadAbort.' cmd.Connection = _connection cmd.CommandTimeout = 300 _connection.Open() Logging.DebugEvent.Log(String.Format("Connection opened,using packet size of {0}.",_connection.PacketSize)) _xmlReader = cmd.ExecuteXmlReader() 'Thread aborts in here' Logging.DebugEvent.Raise(Me.GetType.Namespace,_ "Report data recieved from database") _xmlDoc = New XmlDocument() _xmlDoc.Load(_xmlReader) _xmlReader.Close() End Using Return _xmlDoc End Function 堆 Exception String - 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.TdsParser.Run(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,RunBehavior runBehavior,String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,Boolean returnStream,Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method,DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method) at System.Data.SqlClient.SqlCommand.ExecuteXmlReader()... 解决方法
我相信我已经解决了这个问题.上面例子中令人讨厌的代码行是声明……
Logging.DebugEvent.Raise(Me.GetType.Namespace,_ "Report data recieved from database") 这是对应用程序块(MS企业库)的调用,用于将事件记录到平面文件(在本例中)或事件日志. 这个,在ExecuteXMLReader()和XML文档中读者的实际用法之间,有时会严重失败,导致整个线程中止.我将行移到了_xmlReader.Close()之后,它解决了这个问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Oracle表空间(tablespaces)
- cocos2d-x v2 和 v3 对照手册
- 在流星项目中获得“错误:顶级依赖所需的潜在不兼容的更改”
- reactjs – 在React-Router v4中以编程方式导航
- 正则表达式在python中的简单使用
- 转载: 《Flash:DisplayObject的矩阵旋转(移动/修改注册点
- xcode – 如何在单击按钮时将UIView添加为UIViewController
- objective-c – iOS 6 UIInterfacePortrait ONLY视图控制器
- ruby-on-rails – 使用Rails的Heroku错误:语法错误,意外的
- c – 如何停止/中断boost :: thread?