A thorny IIS deadlock caused by Autofac - iis
I am a Autofac user, now face a very headache problem. I have been asked this question by Email Alex and Travis, and got their reply, here, thank them for their help.
To thoroughly check this problem, I accepted the recommendations of Travis, published the details here.
My Email:
We use Autofac 2.6.3.862 in a mvc3 project .
Now we come to the IIS deadlock problem is serious, the server often
hanging, we have used the Microsoft Debug Diagnostics Tool to do the
analysis (leads to enclose the analysis report ), initially suspected
to be a lock in LifetimeScope
I have read your article, but for some technical details are vague to
me. Most of our Register() component is SingleInstance, so when
Resolve() I doesn't use a a child lifetime scope like using (var scope
= Container.BeginLifetimeScope())
, do not know whether this is the reasons of deadlock.
Debug Diagnostics analysis report
The following threads in
w3wp.exe__hg__PID__3904__Date__03_07_2013__Time_11_01_07AM__974__Manual Dump.dmp are waiting to enter a .NET Lock which thread 39 is currently holding
( 26 34 42 43 44 45 46 47 48 )
16.67% of threads blocked
======================================================================================
Detected possible blocking or leaked critical section at 0x0e758a00 owned by thread 26 in w3wp.exe__hg__PID__3904__Date__03_07_2013__Time_11_01_07AM__974__Manual Dump.dmp
Impact of this lock
1.85% of threads blocked
(Threads 39)
The following functions are trying to enter this critical section
clr!UnsafeEEEnterCriticalSection+1c
The following module(s) are involved with this critical section
C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
======================================================================================
Thread 26 - System ID 7628
Entry point 0x00000000
Create time 2013/3/7 10:44:15
Time spent in user mode 0 Days 00:00:00.218
Time spent in kernel mode 0 Days 00:00:00.343
This thread is waiting to enter a .NET Lock which thread 39 is currently holding
.NET Call Stack
Function
System.Threading.Monitor.ReliableEnter(System.Object, Boolean ByRef)
System.Threading.Monitor.Enter(System.Object, Boolean ByRef)
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Container.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1, System.Object ByRef)
Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1)
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext)
Tunynet.DIContainer.Resolve[[System.__Canon, mscorlib]]()
Spacebuilder.Common.ProfileRepository..cctor()
Spacebuilder.Common.ProfileRepository..ctor()
Spacebuilder.Common.UserProfileService..ctor()
Spacebuilder.Common.User.get_Profile()
ASP._Page_Themes_Channel_Default_Views_FindUser__QuickSearch_cshtml.Execute()
System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
Tunynet.UI.ThemedWebViewPage.ExecutePageHierarchy()
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext, System.IO.TextWriter, System.Web.WebPages.WebPageRenderingBase)
Tunynet.UI.ThemedRazorView.RenderView(System.Web.Mvc.ViewContext, System.IO.TextWriter, System.Object)
System.Web.Mvc.BuildManagerCompiledView.Render(System.Web.Mvc.ViewContext, System.IO.TextWriter)
System.Web.Mvc.ViewResultBase.ExecuteResult(System.Web.Mvc.ControllerContext)
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionResult)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.b__19()
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b()
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b()
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b()
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.b__1b()
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(System.Web.Mvc.ControllerContext, System.Collections.Generic.IList`1, System.Web.Mvc.ActionResult)
System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String)
System.Web.Mvc.Controller.ExecuteCore()
System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext)
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(System.Web.Routing.RequestContext)
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.b__5()
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.b__0()
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass8`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].b__7(System.IAsyncResult)
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].End()
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.b__d()
System.Web.Mvc.SecurityUtil.b__0(System.Action)
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(System.Action)
System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult)
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(System.IAsyncResult)
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
Full Call Stack
Function Source
ntdll!KiFastSystemCallRet
ntdll!NtWaitForMultipleObjects+c
KERNELBASE!WaitForMultipleObjectsEx+100
kernel32!WaitForMultipleObjectsExImplementation+e0
clr!WaitForMultipleObjectsEx_SO_TOLERANT+56
clr!Thread::DoAppropriateAptStateWait+4d
clr!Thread::DoAppropriateWaitWorker+17d
clr!Thread::DoAppropriateWait+60
clr!CLREvent::WaitEx+106
clr!CLREvent::Wait+19
clr!AwareLock::EnterEpilogHelper+a8
clr!AwareLock::EnterEpilog+42
clr!AwareLock::Enter+5f
clr!AwareLock::Contention+228
clr!JITutil_MonReliableContention+e8
System.Threading.Monitor.Enter(System.Object, Boolean ByRef)
clr!CallDescrWorker+33
clr!CallDescrWorkerWithHandler+8e
clr!DispatchCallBody+20
clr!DispatchCallDebuggerWrapper+75
clr!DispatchCallNoEH+53
clr!MethodTable::RunClassInitEx+f1
clr!MethodTable::DoRunClassInitThrowing+53e
clr!MethodDesc::DoPrestub+f1
clr!PreStubWorker+12c
0x00f80842
clr!MethodTable::GetRestoredSlot+2a
clr!MethodDesc::GetMethodEntryPoint+4e
clr!MethodDesc::DoPrestub+51d
clr!PreStubWorker+15d
0x00f80842
System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
System.Collections.Generic.Stack`1[[System.__Canon, mscorlib]].Push(System.__Canon)
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext, System.IO.TextWriter, System.Web.WebPages.WebPageRenderingBase)
System.RuntimeType+ActivatorCacheEntry..ctor(System.Type, System.RuntimeMethodHandleInternal, Boolean)
System.Web.Mvc.BuildManagerCompiledView.Render(System.Web.Mvc.ViewContext, System.IO.TextWriter)
System.Web.Mvc.ViewResultBase.ExecuteResult(System.Web.Mvc.ControllerContext)
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionResult)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(System.Web.Mvc.IResultFilter, System.Web.Mvc.ResultExecutingContext, System.Func`1<System.Web.Mvc.ResultExecutedContext>)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass1c+<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String)
System.Web.Mvc.Controller.ExecuteCore()
System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext)
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(System.Web.Routing.RequestContext)
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.<BeginProcessRequest>b__5()
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.<MakeVoidDelegate>b__0()
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.<EndProcessRequest>b__d()
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(System.Action)
System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult)
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(System.IAsyncResult)
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
webengine4!W3_MGD_HANDLER::ProcessNotification+5b
webengine4!W3_MGD_HANDLER::DoWork+250
webengine4!RequestDoWork+2da
webengine4!CMgdEngHttpModule::OnExecuteRequestHandler+1a
iiscore!NOTIFICATION_CONTEXT::RequestDoWork+128
iiscore!NOTIFICATION_CONTEXT::CallModulesInternal+305
iiscore!NOTIFICATION_CONTEXT::CallModules+28
iiscore!W3_CONTEXT::DoStateRequestExecuteHandler+36
iiscore!W3_CONTEXT::DoWork+d7
iiscore!W3_MAIN_CONTEXT::ContinueNotificationLoop+1f
iiscore!W3_MAIN_CONTEXT::ProcessIndicateCompletion+1f
iiscore!W3_CONTEXT::IndicateCompletion+75
webengine4!W3_MGD_HANDLER::IndicateCompletion+3d
webengine4!MgdIndicateCompletion+24
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
clr!UM2MThunk_WrapperHelper+10
clr!UM2MThunk_Wrapper+8c
clr!Thread::DoADCallBack+f0
clr!UM2MDoADCallBack+c0
0x00f98c20
webengine4!W3_MGD_HANDLER::ProcessNotification+5b
webengine4!ProcessNotificationCallback+36
clr!UnManagedPerAppDomainTPCount::DispatchWorkItem+195
clr!ThreadpoolMgr::NewWorkerThreadStart+20b
clr!ThreadpoolMgr::WorkerThreadStart+3d1
clr!Thread::intermediateThreadProc+4b
kernel32!BaseThreadInitThunk+e
ntdll!__RtlUserThreadStart+70
ntdll!_RtlUserThreadStart+1b
=========================================================================
Thread 39 - System ID 4176
Entry point 0x00000000
Create time 2013/3/7 10:44:21
Time spent in user mode 0 Days 00:00:00.140
Time spent in kernel mode 0 Days 00:00:00.109
This thread is not fully resolved and may or may not be a problem. Further analysis of these threads may be required.
.NET Call Stack
Function
Spacebuilder.Common.ProfileRepository..ctor()
Spacebuilder.Common.UserProfileService..ctor()
Spacebuilder.Common.UserSearcher..ctor(System.String, System.String, Boolean, Int32)
Spacebuilder.Environments.Starter.b__54(Autofac.IComponentContext)
Autofac.RegistrationExtensions+<>c__DisplayClass10`1[[System.__Canon, mscorlib]].b__f(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.Builder.RegistrationBuilder+<>c__DisplayClass1`1[[System.__Canon, mscorlib]].b__0(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable`1)
Autofac.Core.Resolving.InstanceLookup.b__0()
Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(System.Guid, System.Func`1)
Autofac.Core.Resolving.InstanceLookup.Execute()
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope, Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Resolving.InstanceLookup.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4+<>c__DisplayClass6.b__1(Autofac.Core.IComponentRegistration)
System.Linq.Enumerable+WhereSelectArrayIterator`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].MoveNext()
System.Linq.Buffer`1[[System.__Canon, mscorlib]]..ctor(System.Collections.Generic.IEnumerable`1)
System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib]](System.Collections.Generic.IEnumerable`1)
Autofac.Features.Collections.CollectionRegistrationSource+<>c__DisplayClass4.b__0(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Resolving.InstanceLookup.Activate(System.Collections.Generic.IEnumerable`1)
Autofac.Core.Resolving.InstanceLookup.Execute()
Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(Autofac.Core.ISharingLifetimeScope, Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Resolving.ResolveOperation.Execute(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.Core.Container.ResolveComponent(Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable`1)
Autofac.ResolutionExtensions.TryResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1, System.Object ByRef)
Autofac.ResolutionExtensions.ResolveService(Autofac.IComponentContext, Autofac.Core.Service, System.Collections.Generic.IEnumerable`1)
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext, System.Collections.Generic.IEnumerable`1)
Autofac.ResolutionExtensions.Resolve[[System.__Canon, mscorlib]](Autofac.IComponentContext)
Tunynet.DIContainer.Resolve[[System.__Canon, mscorlib]]()
Spacebuilder.Search.SearcherFactory.GetSearcher(System.String)
Spacebuilder.Common.FindUserController._InterestedWithAll(Int32, Int32, System.String)
DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure, System.Web.Mvc.ControllerBase, System.Object[])
System.Web.Mvc.ActionMethodDispatcher.Execute(System.Web.Mvc.ControllerBase, System.Object[])
System.Web.Mvc.ReflectedActionDescriptor.Execute(System.Web.Mvc.ControllerContext, System.Collections.Generic.IDictionary`2)
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionDescriptor, System.Collections.Generic.IDictionary`2)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15.b__12()
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(System.Web.Mvc.IActionFilter, System.Web.Mvc.ActionExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15+<>c__DisplayClass17.b__14()
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(System.Web.Mvc.IActionFilter, System.Web.Mvc.ActionExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15+<>c__DisplayClass17.b__14()
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(System.Web.Mvc.IActionFilter, System.Web.Mvc.ActionExecutingContext, System.Func`1)
System.Web.Mvc.ControllerActionInvoker+<>c__DisplayClass15+<>c__DisplayClass17.b__14()
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(System.Web.Mvc.ControllerContext, System.Collections.Generic.IList`1, System.Web.Mvc.ActionDescriptor, System.Collections.Generic.IDictionary`2)
System.Web.Mvc.ControllerActionInvoker.InvokeAction(System.Web.Mvc.ControllerContext, System.String)
System.Web.Mvc.Controller.ExecuteCore()
System.Web.Mvc.ControllerBase.Execute(System.Web.Routing.RequestContext)
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(System.Web.Routing.RequestContext)
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.b__5()
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.b__0()
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass8`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].b__7(System.IAsyncResult)
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc]].End()
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.b__d()
System.Web.Mvc.SecurityUtil.b__0(System.Action)
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(System.Action)
System.Web.Mvc.MvcHandler.EndProcessRequest(System.IAsyncResult)
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(System.IAsyncResult)
System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)
System.Web.HttpApplication+PipelineStepManager.ResumeSteps(System.Exception)
System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, System.AsyncCallback)
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
DomainNeutralILStubClass.IL_STUB_PInvoke(IntPtr, System.Web.RequestNotificationStatus ByRef)
System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus ByRef)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
Full Call Stack
Function Source
ntdll!KiFastSystemCallRet
ntdll!NtWaitForSingleObject+c
ntdll!RtlpWaitOnCriticalSection+13e
ntdll!RtlEnterCriticalSection+150
clr!UnsafeEEEnterCriticalSection+1c
clr!CrstBase::Enter+1ad
clr!ListLockEntry::FinishDeadlockAwareEnter+25
clr!ListLockEntry::LockHolder::DeadlockAwareAcquire+28
clr!MethodTable::DoRunClassInitThrowing+4c2
clr!MethodDesc::DoPrestub+f1
clr!PreStubWorker+12c
0x00f80842
clr!PreStubWorker+165
System.Linq.Enumerable+WhereSelectArrayIterator`2[[System.__Canon, mscorlib],[System.__Canon, mscorlib]].MoveNext()
System.Linq.Buffer`1[[System.__Canon, mscorlib]]..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)
System.Linq.Enumerable.ToArray[[System.__Canon, mscorlib]](System.Collections.Generic.IEnumerable`1<System.__Canon>)
System.Collections.Generic.Stack`1[[System.__Canon, mscorlib]].Push(System.__Canon)
clr!JIT_Stelem_Ref+25
System.Collections.Generic.Stack`1[[System.__Canon, mscorlib]].Push(System.__Canon)
Alex Reply:
This does sound like a tricky one. What is the DIContainer class doing
and do you have any components registered as InstancePerHttpRequest,
or InstancePerLifetimeScope? There also seems to be some Quartz jobs
in the background too, how are they interacting with the container?
Travis Reply:
A very quick look at the stack trace indicates you may have some
long-running operations or locks happening in the
Spacebuilder.Environments.Starter,
Spacebuilder.Common.UserSearcher.ctor,
Spacebuilder.UserProfileService.ctor, or
Spacebuilder.Common.ProfileRepository. What I'm seeing that's
interesting is that during a RESOLVE operation, when whatever
component it is gets RESOLVED, there's an internal REGISTER going on.
Without seeing the code, I can't tell you what's going on there, but
that thread - #39 - that's the stuff I'd look at.
It looks like... A controller action is being invoked There's some
sort of lambda running over a closure (DynamicClass.lambda_method) -
something custom in your pipeline. SearcherFactory.GetSearcher
manually tries to resolve smoething. During the resolution in
GetSearcher, something is asking for a collection - like an
IEnumerable of services. A constructor parameter? Here's where it
gets weird: while resolving that IEnumerable, a new lifetime scope
is getting created and something appears to be getting registered in
it? The LifetimeScope.ResolveComponent call does do a lock to make
sure resolutions are thread-safe. The fact you're getting a deadlock
means two different threads are trying to resolve out of the same
lifetime scope (the container?) at the same time, which, in MVC, is
something to avoid - you probably wouldn't run into this, for example,
if you were resolving only out of the HttpRequest lifetime scope since
you'd only have that on one thread at a time. Alternatively, you may
be passing lifetime scopes around in the app for the purposes of doing
service location and that, too, can be a red flag.
There is a wiki page on Concurrency that can also give you some
pointers: https://code.google.com/p/autofac/wiki/Concurrency
If that doesn't get you going in the direction you need, I recommend
posting to the discussion forum since, again, I'm not really able to
provide individual help necessarily in a timely fashion. That will get
other eyes on it and may get you help sooner. You'll want to include:
A description of the problem (like was in this email) but with more
detail about what you expect to happen (e.g., you're accessing a
controller action that does blah blah blah). The stack trace of the
blocking thread. The code around where things are getting blocked:
Your initial ContainerBuilder registrations to show how things are
getting registered. What's in those constructors and things that are
getting hung. That info will help folks more quickly root out the
problem. That's also the stuff you should be looking at with respect
to things getting locked
My Supplementary question detail:
The server often irregular hanging, the browser will stop responding suddenly util we use iisreset command to restart the server. I'm not sure if a controller is called or some Quartz tasks triggered that time.
In Application_Start(), we use ContainerBuilder.Register() to regist many components in the same root lifetime scope. And These components may call each other.
Most them registered as SingleInstance, such as:
containerBuilder.Register(c => new DefaultCacheService(new MemcachedCache())).As<ICacheService>().SingleInstance();
containerBuilder.Register(c => new QuartzTaskScheduler()).As<ITaskScheduler>().SingleInstance();
containerBuilder.Register(c => new UserService()).As<IUserService>().SingleInstance();
containerBuilder.Register(c => new UserSearcher("~/App_Data/IndexFiles/User")).As<ISearcher>().SingleInstance();
containerBuilder.Register(c => new TagSearcher("~/App_Data/IndexFiles/Tag")).As<ISearcher>().SingleInstance();
Only a few registered as InstancePerHttpRequest, these component initialization with each request related. such as:
containerBuilder.Register(c => new FormsAuthenticationService()).As<IAuthenticationService>().InstancePerHttpRequest();
We provide a class(DIContainer) includes some simple static methods for component resolve. The static method is called when to resolve a component, such as in some Controller, Service, Repository(DAO) or Quartz tasks.
IContainer container = containerBuilder.Build();
DIContainer.RegisterContainer(container);
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
public class DIContainer
{
private static IContainer _container;
public static void RegisterContainer(IContainer container)
{
_container = container;
}
public static TService Resolve<TService>()
{
return _container.Resolve<TService>();
}
......
}
We use Lucene.Net for fulltext search service, each ISearcher corresponds to a type of search and an index directory. A ISearcher is resolved in SearcherFactory.GetSearcher() when needed.
public static ISearcher GetSearcher(string IndexPath)
{
return DIContainer.Resolve<IEnumerable<ISearcher>>().Where(s => s.IndexPath.Equals(IndexPath, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
}
So that is, but I still can not figure out the root reason. Wishing your help.
Resolve Method's inner implement is LifetimeScope.GetOrCreateAndShare,this method uses a thread lock. Check ProfileRepository's static constructor, maybe the constructor's thread lock and autofac's thread lock constitute a deadlock.
Related
HaxeDevelop Problem "Binary stream '0' does not contain a valid BinaryHeader"
I'm currently new in Haxe, when i open up HaxeDevelop software it shows this error code: Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization. at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at PluginCore.Utilities.ObjectSerializer.InternalDeserialize(String file, Type type) at PluginCore.Utilities.ObjectSerializer.Deserialize(String file, Object obj, Boolean checkValidity) Can someone help me? Here's the Window Image I also did trying reinstalling it several times, it does not work.
What version you're using? Try to download dev version of HaxeDevelop or FlashDevelop (it should work same)
VB6/VBA Iterate through all predeclared class objects
Can I dynamically iterate over all Predeclared objects? This is a problem I've been dealing with for a while now. Ideally I'd iterate through all classes and check if they implement some interfaces. If they do then execute some code on them. Currently I have to provide some array of classes to execute e.g: ClassesToCheck = Array(Task_Class1,Task_Class2,Task_Class3,Task_Class4, ...) Dim klass as object For each klass in ClassesToCheck if klass.implements(ITask) then Call klass.execute() end if next In an ideal world I would do something like this: Dim klass as object For each klass in GET_PREDECLARED_CLASS_OBJECTS_FROM_MEMORY() if klass.implements(ITask) then Call klass.execute() end if next I don't expect there is any easy way to do this, but I have done a little research/exploration of the VBA runtime memory... I think it should be possible and have found some VB6 examples of this using the VBA6.DLL, however, unfortunately this DLL is not provided in Microsoft Office natively. However, the VBA6.DLL is likely 'compiled into' Microsoft Office itself. So the methods/fields should also be held in memory somewhere, you just need to know where they are using pointer math (is my theory) I don't suppose anyone has had any experience with this?
A VB_PredeclaredId attribute makes your Class1 identifier automatically refer to a global-scope object by that name, e.g. UserForm1 is the name of a class module (one with a designer, but that part is irrelevant), and it's the name of a global, automagic object spawned by VBA at runtime, and the compiler knows Class1.DoStuff is legal because it knows Class1 has VB_PredeclaredId set to True. Thanks to the work and contributions of Wayne Phillips (vbWatchDog) and other contributors, Rubberduck taps into this internal API. As shown in the linked code (C#), you can get ahold of the ITypeLib for a VBA project from its References collection, by turning the pointer into a struct with this specific layout: [StructLayout(LayoutKind.Sequential)] internal struct VBEReferencesObj { IntPtr _vTable1; // _References vtable IntPtr _vTable2; IntPtr _vTable3; IntPtr _object1; IntPtr _object2; public IntPtr _typeLib; // <--- here's the pointer you want IntPtr _placeholder1; IntPtr _placeholder2; IntPtr _refCount; } In VBA that would be a user-defined Type that might look like this: Public Type VBEReferencesObj vTable1 As LongPtr vTable2 As LongPtr vTable3 As LongPtr object1 As LongPtr object2 As LongPtr typelibPointer As LongPtr '<~ only this one matters placeholder1 As LongPtr placeholder2 As LongPtr refCount As LongPtr End Type Once you have the pointer to the ITypeLib, you should be able to get the VBA project's type library. From there, you'll want to iterate the types, and from there determine whether the type's TYPEFLAGS has TYPEFLAG_PREDECLID turned on (we do this here). Obviously this is a lot of extremely crash-prone trial-and-error coding, and I wouldn't recommend doing any of this, but in any case, it's possible, if not adviseable. Feel free to study Rubberduck.VBEEditor.ComManagement.TypeLibs namespaces.
I don't know how to leverage the tlbinf32.dll, to get class info directly from memory, however, If you stuck with you current approach, but used a collection of objects instead of an array of objects, you could do the following: Private ConditionalExecution() Dim PredeclaredClasses As Collection Set PredeclaredClasses = New Collection PredeclaredClasses.Add Task_Class1 PredeclaredClasses.Add Task_Class2 PredeclaredClasses.Add Task_Class3 PredeclaredClasses.Add Task_Class4 ExecuteIfImplementsInterface PredeclaredClasses End Sub Private Sub ExecuteIfImplementsInterface(ByVal Classes As Collection) Dim klass as object For each klass in classes If TypeOf klass Is ITask Then klass.execute() next End Sub Ofcourse this would be contigent on the fact that these classes would have to be instantiated via "dimming" them as the interface they are implementing like so: Dim bar As ITask Set bar = New Task_Class1 SideNote: If you were wondering, Yes I suck at coming up with method names.
How to get file stream from the sharepoint file url in dynamic crm plugin?
I have requirement to get file stream of share point file, for the that I have share point file URL. https://mysite.sharepoint.com/sites/documents/contact/test/Beat01_07262017.pdf I’m trying to connect to SharePoint Online (using CSOM) from within a plugin in CRM Online . For that to work, I merged the SharePoint Client and Client.Runtime DLL’s with ilmerge.exe into my plugin DLL. But as soon as the following code: ClientContext clientContext = new ClientContext(server); clientContext.Credentials = new SharePointOnlineCredentials(UserId, Password); // This line throws an below exception: Request for the permission of type ‘System.Security.Permissions.RegistryPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed. Is there any way to make it working? I have checked with SharePoint Integration from CRM Online Workflow/Plugin but not able to get it working and getting error as below Exception: Exception has been thrown by the target of an invocation. Stack Trace 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 Microsoft.Xrm.Sdk.Linq.QueryProvider.DynamicInvoke(Delegate project, Object[] args) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateExpressionToConditionValue(Expression exp, ParameterExpression[] parameters) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereCondition(BinaryExpression be, FilterExpressionWrapper parentFilter, Func 2 getFilter, Func 2 getLinkLookup, Boolean negate) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(String parameterName, BinaryExpression be, FilterExpressionWrapper parentFilter, Func 2 getFilter, List 1 linkLookups, Boolean negate) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereBoolean(String parameterName, Expression exp, FilterExpressionWrapper parentFilter, Func 2 getFilter, List 1 linkLookups, BinaryExpression parent, Boolean negate) at Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(QueryExpression qe, String parameterName, Expression exp, List 1 linkLookups) at Microsoft.Xrm.Sdk.Linq.QueryProvider.GetQueryExpression(Expression expression, Boolean& throwIfSequenceIsEmpty, Boolean& throwIfSequenceNotSingle, Projection& projection, NavigationSource& source, List 1& linkLookups) at Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute[TElement](Expression expression) at Microsoft.Xrm.Sdk.Linq.QueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression) at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable 1 source) at CRMPluginProject1._365Immo.Laurus.SharePoint.DocumentLocationHelper.GetDocumentLocationPath(SharePointDocumentLocation parentLocation) at CRMPluginProject1._365Immo.Laurus.SharePoint.DocumentLocationHelper.CreateDocumentLocation(Entity site, String documentLibraryName, EntityReference regardingRecord) at CRMPluginProject1._365Immo.Laurus.Plugins.GetSharePointFile.Execute(IServiceProvider serviceProvider) Inner Exception : The demand failed due to the code access security information captured during the creation of an anonymously hosted dynamic method. In order for this operation to succeed, ensure that the demand would have succeeded at the time the method was created. See http://go.microsoft.com/fwlink/?LinkId=288746 for more information. Stack Trace : at lambda_method(Closure )
The SharePoint client library apparently needs access to the Windows registry. This is not allowed in sandboxed CRM plugins. In sandboxed plugins code is only allowed to access resources on the web using the http or https protocol. (IP addresses are not allowed either.)
PowerQuery table refresh stops with an error
I have experienced several time situation where using power query and refreshing large table (~300K rows) it stops loading rows with an error: Error Message: The MashupResource's PageReader is not available. Stack Trace: System.InvalidOperationException: The MashupResource's PageReader is not available. at Microsoft.Mashup.Client.Excel.FillManager.RefreshFillSession.GetSchemaInfo() at Microsoft.Mashup.Client.Excel.FillManager.RefreshFillSession.CompleteRefresh(IWorkbook workbook, Boolean onTimer) at Microsoft.Mashup.Client.Excel.FillManager.RefreshFillSession.UpdateRefreshStatus(IWorkbook workbook, Boolean onTimer) at Microsoft.Mashup.Client.Excel.FillManager.RefreshFillSession.ResumeFill(Boolean onTimer) at Microsoft.Mashup.Client.Excel.FillManager.UpdateQueries() at Microsoft.Mashup.Client.Excel.FillManager.b__5() at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action) Invocation Stack Trace: at Microsoft.Mashup.Host.Document.ExceptionExtensions.GetCurrentInvocationStackTrace() at Microsoft.Mashup.Client.ClientShared.StackTraceInfo..ctor(String exceptionStackTrace, String invocationStackTrace) at Microsoft.Mashup.Client.ClientShared.ErrorDetails..ctor(String message, Nullable`1 errorCode, String requestId, Exception exception) at Microsoft.Mashup.Client.ClientShared.UnexpectedExceptionHandler.<>c__DisplayClass1.b__0() at Microsoft.Mashup.Host.Document.SynchronizationContextExtensions.Send(SynchronizationContext context, IExceptionHandler exceptionHandler, Action callback) at Microsoft.Mashup.Client.ClientShared.UnexpectedExceptionHandler.HandleException(Exception e) at Microsoft.Mashup.Host.Document.ExceptionHandlerExtensions.HandleExceptions(IExceptionHandler exceptionHandler, Action action) at Microsoft.Mashup.Client.Excel.FillManager.OnFillUpdateTimerTick(Object sender, EventArgs eventArgs) at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) MashupResource.Status Initializing I get this error when some table is refreshing and I try to use other excel file. Do anyone have an idea what does it mean? I have tried searching it in google with no success. I am using Excel 2010 32bit, version 14.0.7015.1000 and PowerQuery version 2.27.4163.242
Sorry you ran into this problem, the message indicates there's some bug in Power Query. If you could try upgrading to the latest public Power Query (we're at version 2.30 now) does the problem go away? If not, it might be easiest to Send a Frown from the error prompt and you can get in touch with our super-helpful support team?
PowerShell and SharePoint 2007: Cannot find an overload for "Add" and the argument count: "2"
I am trying to write a PowerShell script to enable a feature on all subwebs of a given site collection and everything was going swimmingly until I tried to get the actual feature to be enabled. I am successful in using the SharePoint API everywhere, but when i get to this: $activatedFeature = $web.Features.Add($Feature.Id, $true) I am getting a ridiculous exception that I cant seem to figure out. System.Management.Automation.MethodException: Cannot find an overload for "Add" and the argument count: "2". at System.Management.Automation.Adapter.FindBestMethod(String methodName, MethodInformation[] methods, Object[] arguments, Boolean& expandParamsOnBest) at System.Management.Automation.DotNetAdapter.MethodInvokeDotNet(String methodName, Object target, MethodInformation[] methodInformation, Object[] arguments) at System.Management.Automation.Adapter.BaseMethodInvoke(PSMethod method, Object[] arguments) at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet) at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value) at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe, ExecutionContext context) at System.Management.Automation.AssignmentStatementNode.Execute(Array input, Pipe outputPipe, ExecutionContext context) at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context) I cant say that this exception makes much sense to me, nor can I find anything helpful from resources here or searching on key terms. Has anyone experienced something like this before? If so, how do i correct it.
I had written a function to return the SPFeatureDefinition of the feature being activated and apparently it was returning an array of two items. The second item in the array was the SPFeatureDefinition and I was not aware of this. So, after calling that function i did this: $Feature = $Feature[1] After this, everything worked fine.