1.5.1 Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.

Topics: General, Troubleshooting
Aug 7, 2012 at 11:49 AM
Edited Aug 7, 2012 at 11:52 AM

I'm trying to setup a new site on the shared hosting and get the following error:

Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.]
   Autofac.Core.Lifetime.LifetimeScope.CheckNotDisposed() +57
   Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters) +59
   lambda_method(Closure ) +96
   Orchard.Environment.DefaultOrchardShell.Terminate() in c:\Build\Orchard\src\Orchard\Environment\DefaultOrchardShell.cs:51
   Orchard.Environment.DefaultOrchardHost.ActivateShell(ShellSettings settings) in c:\Build\Orchard\src\Orchard\Environment\DefaultOrchardHost.cs:267
   Orchard.Environment.DefaultOrchardHost.StartUpdatedShells() in c:\Build\Orchard\src\Orchard\Environment\DefaultOrchardHost.cs:116
   Orchard.Environment.DefaultOrchardHost.BeginRequest() in c:\Build\Orchard\src\Orchard\Environment\DefaultOrchardHost.cs:215
   Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.BeginRequest() in c:\Build\Orchard\src\Orchard\Environment\DefaultOrchardHost.cs:78
   Orchard.Web.MvcApplication.HostBeginRequest(HttpApplication application, IOrchardHost host) in c:\Build\Orchard\src\Orchard.Web\Global.asax.cs:38
   Orchard.WarmupStarter.Starter`1.OnBeginRequest(HttpApplication application) in c:\Build\Orchard\src\Orchard.WarmupStarter\Starter.cs:68
   Orchard.Web.MvcApplication.Application_BeginRequest() in c:\Build\Orchard\src\Orchard.Web\Global.asax.cs:29

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0
   System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +72
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +335
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
   System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
   System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +57
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

 

Does somebody have an idea how to fix that issue taking into account that I don't have an access to the server configuration?

Developer
Aug 8, 2012 at 4:42 PM

Did you try these posts?

http://orchard.codeplex.com/discussions/359010
http://orchard.codeplex.com/discussions/362244
http://orchard.codeplex.com/discussions/353349
http://orchard.codeplex.com/discussions/351465
http://orchard.codeplex.com/discussions/349996
http://orchard.codeplex.com/discussions/346877

 

Aug 27, 2012 at 12:55 PM

I have the similar problem. When I click Navigation admin menu item it stops in DefaultContentmanager in this code on the second line. It was under IIS Express. It seems it works under development server though.

public virtual ContentItem Get(int id, VersionOptions options, QueryHints hints) {
            var session = _contentManagerSession();
            ContentItem contentItem;

            ContentItemVersionRecord versionRecord = null;

            // obtain the root records based on version options
            if (options.VersionRecordId != 0) {
                // short-circuit if item held in session
                if (session.RecallVersionRecordId(options.VersionRecordId, out contentItem)) {
                    return contentItem;
                }

System.ObjectDisposedException was unhandled by user code
  Message=Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
  Source=Autofac
  ObjectName=""
  StackTrace:
       at Autofac.Core.Lifetime.LifetimeScope.CheckNotDisposed()
       at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
       at lambda_method(Closure )
       at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in C:\ProjectsY\Orchard.1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 115
       at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options) in C:\ProjectsY\Orchard.1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 111
       at Orchard.ContentManagement.DefaultContentManager.Get(Int32 id) in C:\ProjectsY\Orchard.1.5\src\Orchard\ContentManagement\DefaultContentManager.cs:line 107
       at Orchard.ContentManagement.ContentGetExtensions.Get[T](IContentManager manager, Int32 id) in C:\ProjectsY\Orchard.1.5\src\Orchard\ContentManagement\ContentExtensions.cs:line 152
       at Orchard.Core.Common.Handlers.CommonPartHandler.<>c__DisplayClassa.<LazyLoadHandlers>b__8() in C:\ProjectsY\Orchard.1.5\src\Orchard.Web\Core\Common\Handlers\CommonPartHandler.cs:line 127
       at Orchard.Core.Common.Utilities.LazyField`1.GetValue() in C:\ProjectsY\Orchard.1.5\src\Orchard.Web\Core\Common\Utilities\LazyField.cs:line 24
       at Orchard.Core.Common.Utilities.LazyField`1.get_Value() in C:\ProjectsY\Orchard.1.5\src\Orchard.Web\Core\Common\Utilities\LazyField.cs:line 10
       at GetValue(Object )
       at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
  InnerException:

Coordinator
Aug 28, 2012 at 4:47 AM

And did you read the posts linked by Sipke?

Aug 28, 2012 at 5:44 PM

Yes and found nothing relevant because I am working with the development server.

Developer
Aug 28, 2012 at 11:28 PM

Perhaps try out IIS (not express)? Worked for me when I had a similar issue. Back then, the issue was having installed VS2012 Beta + .NET 4.5 beta.