执行 CLR 存储过程时 .NET 框架执行中止?
我构建了一个存储过程,其功能相当于 SQL Server 2008 中的 FOR XML AUTO
。现在我正在测试它,它给了我一条非常无用的错误消息。这个错误是什么意思?
Msg 10329, Level 16, State 49, Procedure ForXML, Line 0 .NET Framework execution was aborted.
System.Threading.ThreadAbortException: Thread was being aborted.
System.Threading.ThreadAbortException:
at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr, Int32 len)
at System.Data.SqlServer.Internal.CXVariantBase.WSTRToString()
at System.Data.SqlServer.Internal.SqlWSTRLimitedBuffer.GetString(SmiEventSink sink)
at System.Data.SqlServer.Internal.RowData.GetString(SmiEventSink sink, Int32 i)
at Microsoft.SqlServer.Server.ValueUtilsSmi.GetValue(SmiEventSink_Default sink, ITypedGettersV3 getters, Int32 ordinal, SmiMetaData metaData, SmiContext context)
at Microsoft.SqlServer.Server.ValueUtilsSmi.GetValue200(SmiEventSink_Default sink, SmiTypedGetterSetter getters, Int32 ordinal, SmiMetaData metaData, SmiContext context)
at System.Data.SqlClient.SqlDataReaderSmi.GetValue(Int32 ordinal)
at System.Data.SqlClient.SqlDataReaderSmi.GetValues(Object[] values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at ForXML.GetXML...
I constructed a stored procedure that does the equivalent of FOR XML AUTO
in SQL Server 2008. Now that I'm testing it, it gives me a really unhelpful error message. What does this error mean?
Msg 10329, Level 16, State 49, Procedure ForXML, Line 0 .NET Framework execution was aborted.
System.Threading.ThreadAbortException: Thread was being aborted.
System.Threading.ThreadAbortException:
at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr, Int32 len)
at System.Data.SqlServer.Internal.CXVariantBase.WSTRToString()
at System.Data.SqlServer.Internal.SqlWSTRLimitedBuffer.GetString(SmiEventSink sink)
at System.Data.SqlServer.Internal.RowData.GetString(SmiEventSink sink, Int32 i)
at Microsoft.SqlServer.Server.ValueUtilsSmi.GetValue(SmiEventSink_Default sink, ITypedGettersV3 getters, Int32 ordinal, SmiMetaData metaData, SmiContext context)
at Microsoft.SqlServer.Server.ValueUtilsSmi.GetValue200(SmiEventSink_Default sink, SmiTypedGetterSetter getters, Int32 ordinal, SmiMetaData metaData, SmiContext context)
at System.Data.SqlClient.SqlDataReaderSmi.GetValue(Int32 ordinal)
at System.Data.SqlClient.SqlDataReaderSmi.GetValues(Object[] values)
at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataTable[] dataTables, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at ForXML.GetXML...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,在 ADO.NET 数据集/表/适配器填充期间发生线程中止异常是因为查询运行时间超过了用于检索数据的任何方法的超时时间。
在您的情况下,您似乎正在使用直接 SQL Server 连接,因此我建议尝试设置 CommandTimeout 将 SQL 命令的属性设置为足够大的值以适应您的查询。或者微调查询甚至应用程序架构以获得更好的性能。
Typically Thread Abort exceptions occurring during ADO.NET DataSet/Table/Adapter filling happen because the query ran longer than the timeout of whatever means was used to retrieve the data.
In your case it looks like you're using a direct SQL Server connection, so I'd say try setting the CommandTimeout property for your SQL command to a sufficiently large value to accommodate your query. That, or fine-tune the query or even the application architecture for better performance.
我很确定这意味着您做错了...
另一方面:看起来您正在填充数据表。在通话过程中,它试图将某些内容转换为字符串值......但失败了。
您必须查看返回的列,看看是否有无法转换为字符串表示形式的列。也许是二进制值或空值,或者类似的东西。
I'm pretty sure it means you did it wrong...
On another note: It looks like you are filling a datatable. during the call it's trying to convert something into a string value.. and failing.
You're going to have to look at the columns that are coming back to see if there is one that can't convert to a string representation. Maybe a binary or null value, or something like that.