LINQ to SQL:间歇性AccessViolationException包装在TargetInvocationException中 [英] LINQ to SQL: intermittent AccessViolationException wrapped in TargetInvocationException

查看:67
本文介绍了LINQ to SQL:间歇性AccessViolationException包装在TargetInvocationException中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几周以来,我们的ASP.Net Web应用程序遇到了W3WP崩溃.这些是在我们的网络服务器更新之后开始的.我们的应用程序没有更改,并且已经稳定了很多年.
我们的情况似乎很像此先前的问题.并且这个问题也可能与此有关,尽管在我们的例子中,查询可以在所用时间的99.9%内正常运行.

Since a few weeks we are experiencing W3WP-crashes with our ASP.Net web application. These started after our webservers were updated. Our application did not change and has been stable for years.
Our situation seems to be a lot like this earlier question. And this question might also be related, though in our case the queries run fine in 99.9% of the times used.

我们使用了许多未编译的LINQ查询,并尝试编译它们是否可以防止这些崩溃.撞车次数急剧减少,但仍然会发生.

We use a lot of uncompiled LINQ queries and tried if compiling them would prevent these crashes. The number of crashes decreased drastically, but they still do occur.

也将查询包装在try catch中,然后捕获TargetInvocationException无效.没有捕获到异常.

Also wrapping our queries in a try catch and then catching the TargetInvocationException does not work. The exception is not caught.

当发生崩溃时,我们会获得WER报告,并且可以检索崩溃转储.
对于未编译的查询,转储中的堆栈跟踪通常如下所示:

When a crash happens, we get a WER-report and can retreive a crash dump.
A stack trace from a dump for an uncompiled query typically looks like this:

在System.RuntimeMethodHandle.InvokeMethod(对象目标,Object []参数,签名sig,布尔值构造函数)
在System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal处(Object obj,Object []参数,Object []参数)
在System.Delegate.DynamicInvokeImpl(Object [] args)
在System.Data.Linq.SqlClient.QueryConverter.VisitInvocation(InvocationExpression invoke)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.VisitExpression(表达式exp)
在System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.VisitExpression(表达式exp)
在System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.Visit(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.VisitWhere(表达序列,LambdaExpression谓词)
在System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.VisitWhere(表达序列,LambdaExpression谓词)
在System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.VisitSelect中(表达序列,LambdaExpression选择器)
在System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.VisitDistinct(表达序列)上
在System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)处
在System.Data.Linq.SqlClient.QueryConverter.VisitInner(表达式节点)上
在System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(表达式节点)上
在System.Data.Linq.SqlClient.SqlProvider.BuildQuery(表达式查询,SqlNodeAnnotations注释)上
在System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(表达式查询)
在System.Data.Linq.DataQuery'1.System.Collections.Generic.IEnumerable.GetEnumerator()
在System.Linq.Buffer'1..ctor(IEnumerable'1源)处
在System.Linq.Enumerable.ToArray [TSource](IEnumerable'1源)上

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Data.Linq.SqlClient.QueryConverter.VisitInvocation(InvocationExpression invoke)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
at System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.VisitExpression(Expression exp)
at System.Data.Linq.SqlClient.QueryConverter.VisitBinary(BinaryExpression b)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.Visit(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.VisitWhere(Expression sequence, LambdaExpression predicate)
at System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.VisitWhere(Expression sequence, LambdaExpression predicate)
at System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.VisitSelect(Expression sequence, LambdaExpression selector)
at System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.VisitDistinct(Expression sequence)
at System.Data.Linq.SqlClient.QueryConverter.VisitSequenceOperatorCall(MethodCallExpression mc)
at System.Data.Linq.SqlClient.QueryConverter.VisitInner(Expression node)
at System.Data.Linq.SqlClient.QueryConverter.ConvertOuter(Expression node)
at System.Data.Linq.SqlClient.SqlProvider.BuildQuery(Expression query, SqlNodeAnnotations annotations)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery'1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Linq.Buffer'1..ctor(IEnumerable'1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable'1 source)

转储的已编译查询的堆栈跟踪如下:

The stack trace from a dump for a compiled query looks like:

在System.RuntimeMethodHandle.InvokeMethod(System.Object,System.Object [],System.Signature,布尔值)上
在System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object,System.Object [],System.Object [])处
在System.Delegate.DynamicInvokeImpl(System.Object [])
在System.Data.Linq.SqlClient.SqlProvider.AssignParameters(System.Data.Common.DbCommand,System.Collections.ObjectModel.ReadOnlyCollection`1,System.Object [],System.Object上)
在System.Data.Linq.SqlClient.SqlProvider.Execute(System.Linq.Expressions.Expression,QueryInfo,System.Data.Linq.SqlClient.IObjectReaderFactory,System.Object [],System.Object [],System.Data.Linq .SqlClient.ICompiledSubQuery [],System.Object)
在System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(System.Linq.Expressions.Expression,QueryInfo [],System.Data.Linq.SqlClient.IObjectReaderFactory,System.Object [],System.Data.Linq.SqlClient.ICompiledSubQuery [])
在System.Data.Linq.SqlClient.SqlProvider + CompiledQuery.Execute(System.Data.Linq.Provider.IProvider,System.Object [])
在System.Data.Linq.CompiledQuery.ExecuteQuery(System.Data.Linq.DataContext,System.Object [])

at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
at System.Delegate.DynamicInvokeImpl(System.Object[])
at System.Data.Linq.SqlClient.SqlProvider.AssignParameters(System.Data.Common.DbCommand, System.Collections.ObjectModel.ReadOnlyCollection`1, System.Object[], System.Object)
at System.Data.Linq.SqlClient.SqlProvider.Execute(System.Linq.Expressions.Expression, QueryInfo, System.Data.Linq.SqlClient.IObjectReaderFactory, System.Object[], System.Object[], System.Data.Linq.SqlClient.ICompiledSubQuery[], System.Object)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(System.Linq.Expressions.Expression, QueryInfo[], System.Data.Linq.SqlClient.IObjectReaderFactory, System.Object[], System.Data.Linq.SqlClient.ICompiledSubQuery[])
at System.Data.Linq.SqlClient.SqlProvider+CompiledQuery.Execute(System.Data.Linq.Provider.IProvider, System.Object[])
at System.Data.Linq.CompiledQuery.ExecuteQuery(System.Data.Linq.DataContext, System.Object[])

有人知道什么可能改变了我们应用程序的行为吗?我们知道它是更新"(但不完全是哪个),但是我们对其技术背景更感兴趣.
当然,我们也欢迎一种解决方案来防止应用程序崩溃.

Does anyone know what might have changed the behavior our application? We know it was "an update" (but not exactly which one), but we are more interested in it's technical background.
Of course, we would also welcome a solution to prevent our application from crashing.

推荐答案

我认为我会发布一个针对该问题的解决方案,因为我们最近开始遇到此问题.

I thought I would post a solution, that we found to this issue, because we started experiencing the problem recently.

我们有许多服务器可以很好地运行我们的代码,但每周只有1台由于此错误而崩溃.我相信该服务器位于.net 4.5.2.上.

We have many servers that run our code just fine but only 1 was crashing a couple of times a week with this error. I believe this server was on .net 4.5.2.

由于未解决的异常发生在他们的堆栈中,所以我们与Microsoft一起开了罚单.

We opened a ticket with Microsoft since the unhandled exception was happening in their stack.

他们查看了我们的转储,然后返回了这个有效的解决方案.

They looked at our dump and came back with this solution which worked.

可以通过以下途径获得新的修复程序: https://support.microsoft.com/en-us/kb/3139544

A new fix is available at https://support.microsoft.com/en-us/kb/3139544

如果您移至.net 4.6.1,那就更好了

It would be better if you move to .net 4.6.1

我希望该解决方案能够帮助发现自己的任何其他人阅读此书.

I hope this solution will help anyone else that finds themselves reading this.

这篇关于LINQ to SQL:间歇性AccessViolationException包装在TargetInvocationException中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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