From time to time I'm getting an Exception of the type System.AccessViolationException in my w3wp.exe that crash the app.
The stack of the exception is this (got from the event viewer):
Log Name: Application
Source: .NET Runtime
Date: 05-04-2013 00:00:27
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: MYSERVER
Description:
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]..ctor()
at System.Data.Common.Internal.Materialization.CoordinatorScratchpad..ctor(System.Type)
at System.Data.Common.Internal.Materialization.Translator.ProcessCollectionColumnMap(System.Data.Query.InternalTrees.CollectionColumnMap, System.Data.Common.Internal.Materialization.TranslatorArg, System.Data.Query.InternalTrees.ColumnMap, System.Object)
at System.Data.Common.Internal.Materialization.Translator.Visit(System.Data.Query.InternalTrees.SimpleCollectionColumnMap, System.Data.Common.Internal.Materialization.TranslatorArg)
at System.Data.Query.InternalTrees.SimpleCollectionColumnMap.Accept[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Data.Common.Internal.Materialization.TranslatorArg, System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Data.Query.InternalTrees.ColumnMapVisitorWithResults`2<System.__Canon,System.Data.Common.Internal.Materialization.TranslatorArg>, System.Data.Common.Internal.Materialization.TranslatorArg)
at System.Data.Common.Internal.Materialization.Translator.TranslateColumnMap[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Data.Common.QueryCache.QueryCacheManager, System.Data.Query.InternalTrees.ColumnMap, System.Data.Metadata.Edm.MetadataWorkspace, System.Data.Objects.Internal.SpanIndex, System.Data.Objects.MergeOption, Boolean)
at System.Data.Common.Internal.Materialization.ShaperFactory+TypedShaperFactoryCreator`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].TypedCreate(System.Data.Common.QueryCache.QueryCacheManager, System.Data.Query.InternalTrees.ColumnMap, System.Data.Metadata.Edm.MetadataWorkspace, System.Data.Objects.Internal.SpanIndex, System.Data.Objects.MergeOption, Boolean)
at System.Data.Common.Internal.Materialization.ShaperFactory.Create(System.Type, System.Data.Common.QueryCache.QueryCacheManager, System.Data.Query.InternalTrees.ColumnMap, System.Data.Metadata.Edm.MetadataWorkspace, System.Data.Objects.Internal.SpanIndex, System.Data.Objects.MergeOption, Boolean)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(System.Data.Objects.ObjectContext, System.Data.Common.CommandTrees.DbQueryCommandTree, System.Type, System.Data.Objects.MergeOption, System.Data.Objects.Span, System.Collections.ObjectModel.ReadOnlyCollection`1<System.Collections.Generic.KeyValuePair`2<System.Data.Objects.ObjectParameter,System.Data.Objects.ELinq.QueryParameterExpression>>)
at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(System.Nullable`1<System.Data.Objects.MergeOption>)
at System.Data.Objects.ObjectQuery`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].GetResults(System.Nullable`1<System.Data.Objects.MergeOption>)
at System.Data.Objects.ObjectQuery`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Linq.Enumerable.Single[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<Boolean>)
at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<Boolean>)
at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IEnumerable`1<Boolean>, System.Linq.Expressions.Expression)
at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Linq.Expressions.Expression)
at System.Linq.Queryable.Any[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Linq.IQueryable`1<System.__Canon>)
at MY.WebService.NetworkValidation.ValidIp(System.String)
at MY.WebService.SedeService.IsLogged(MY.DataBase.SedeData.User)
at MY.WebService.Sede.IsLogged()
at DynamicClass.SyncInvokeIsLogged(System.Object, System.Object[], System.Object[])
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(System.Object, System.Object[], System.Object[] ByRef)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(System.ServiceModel.Dispatcher.MessageRpc ByRef)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean)
at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(System.ServiceModel.Channels.RequestContext, Boolean, System.ServiceModel.OperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(System.ServiceModel.Channels.RequestContext, System.ServiceModel.OperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(System.IAsyncResult)
at System.ServiceModel.Dispatcher.ChannelHandler.OnContinueAsyncReceive(System.Object)
at System.Runtime.IOThreadScheduler+ScheduledOverlapped.IOCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
at System.Runtime.Fx+IOCompletionThunk.UnhandledExceptionFrame(UInt32, UInt32, System.Threading.NativeOverlapped*)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
The code of the function ValidIp(string ip) (last function that I call before get the exception):
try
{
using(var db = new AccessEntities())
{
var ret = db.AccessControl.Where(xx => xx.Ip == ip && xx.IsValid).Any();
return ret;
}
}
catch (Exception ee)
{
return false;
}
Does anyone have any idea why this is happening ? I call this function every 1h and from times to times give this exception, last time took 2 days and half to happen, another interesting thing is I'm doing a try/catch shouldn't I be able to catch the exception and prevent the w3wp.exe crash ?
Thanks in advance, Rui