Getting error after building orchard from source and deploying to IIS

Topics: Installing Orchard, Troubleshooting
Jan 9, 2012 at 5:40 PM
Edited Jan 9, 2012 at 5:56 PM

I built orchard by running ClickToBuild.cmd. I copied the artifacts/MsDeploy/Orchard.Web.zip to my test web server and unzipped to the root of my iis app. 

Go to mysite.com/ and I get the orchard setup page. I fill it out & submit (using "Default" recipe), and get this 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:

Line 23: @if (Model.Messages != null) {
Line 24: 

Line 25:     @Display(Model.Messages)
Line 26: 

Line 27: }

Source File: c:\sites\mysite.com\Themes\SafeMode\Views\Layout.cshtml    Line: 25 

 

Have I done something wrong? The last time I deployed from source, I built in VS and zipped up the Orchard.Web folder and copied that over instead of trying the build scripts that come with the source -- that worked. 

Jan 9, 2012 at 6:22 PM
Edited Jan 9, 2012 at 6:30 PM

Tried again after clearing cookies and closing browser and the problem went away. Not sure what happened here.

Jan 9, 2012 at 7:41 PM

I've been seeing this error in 1.x recently, restarting the web server generally does the trick.

Jan 9, 2012 at 8:07 PM

Are you only getting it during the Orchard setup (e.g. empty App_Data folder)? That's the only time I got it so far. I am using the 1.x branch as well. 

Jan 9, 2012 at 8:42 PM

Come to mention it, probably was on a clean install.

Developer
Jan 10, 2012 at 8:30 PM

I'm getting a similar exception recently, coming from a CacheManager.Get() with the key OrchardHost_Extensions" (DefaultOrchardHost.MonitorExtensions()):

[ObjectDisposedException: Cannot access a disposed object.
Object name: 'TransactionScope'.]
   System.Transactions.TransactionScope.Complete() +83955
   Orchard.Data.TransactionManager.System.IDisposable.Dispose() in \src\Orchard\Data\TransactionManager.cs:43
   Autofac.Core.Disposer.Dispose(Boolean disposing) +130
   Autofac.Util.Disposable.Dispose() +78
   Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) +96
   Autofac.Util.Disposable.Dispose() +78
   Orchard.Environment.DefaultOrchardHost.DisposeShellContext() in \src\Orchard\Environment\DefaultOrchardHost.cs:198
   Orchard.Environment.DefaultOrchardHost.<MonitorExtensions>b__6(AcquireContext`1 ctx) in \src\Orchard\Environment\DefaultOrchardHost.cs:183
   Orchard.Caching.Cache`2.CreateEntry(TKey k, Func`2 acquire) in \src\Orchard\Caching\Cache.cs:57
   Orchard.Caching.Cache`2.UpdateEntry(CacheEntry currentEntry, TKey k, Func`2 acquire) in \src\Orchard\Caching\Cache.cs:33
   Orchard.Caching.<>c__DisplayClass2.<Get>b__1(TKey k, CacheEntry currentEntry) in \src\Orchard\Caching\Cache.cs:21
   System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory) +81
   Orchard.Caching.Cache`2.Get(TKey key, Func`2 acquire) in \src\Orchard\Caching\Cache.cs:17
   Orchard.Caching.DefaultCacheManager.Get(TKey key, Func`2 acquire) in \src\Orchard\Caching\DefaultCacheManager.cs:33
   Orchard.Environment.DefaultOrchardHost.MonitorExtensions() in \src\Orchard\Environment\DefaultOrchardHost.cs:179
   Orchard.Environment.DefaultOrchardHost.BeginRequest() in \src\Orchard\Environment\DefaultOrchardHost.cs:207
   Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.BeginRequest() in \src\Orchard\Environment\DefaultOrchardHost.cs:77
   Orchard.Web.MvcApplication.HostBeginRequest(HttpApplication application, IOrchardHost host) in \src\Orchard.Web\Global.asax.cs:38
   Orchard.WarmupStarter.Starter`1.OnBeginRequest(HttpApplication application) in \src\Orchard.WarmupStarter\Starter.cs:68
   Orchard.Web.MvcApplication.Application_BeginRequest() in \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

 

This happens when I modify a module when in debug mode. This makes me sad :-(. Also 1.x branch, and also goes away with server restart.

Jan 10, 2012 at 8:34 PM

I'm getting lots of those as well. Sebastien said he fixed some problems that were causing this kind of thing but there are still definitely some issues. Sometimes the site just starts intermittently throwing scope errors until I restart/rebuild, sometimes it just gives me one like that permanently.

Coordinator
Jan 10, 2012 at 8:45 PM

Yep, anything showing LifetimeScope in the message is due to the move to Autofac 2.5. It's throwing too often to be acceptable, I will fix it ASAP.

Jan 10, 2012 at 8:49 PM

In case this helps someone debug, I've been running in Release mode since I switched to 1.x, and the only time I've gotten these errors has been when starting a new Orchard instance (delete App_Data folder & start with fresh db). I run the project with Ctrl+F5 while I'm making changes, unless I specifically need to step through code.

Jan 10, 2012 at 9:00 PM
TheMonarch wrote:

In case this helps someone debug, I've been running in Release mode since I switched to 1.x, and the only time I've gotten these errors has been when starting a new Orchard instance (delete App_Data folder & start with fresh db). I run the project with Ctrl+F5 while I'm making changes, unless I specifically need to step through code.

It happens to me all the time, not just clean instances. F5 in the browser consistently fails to trigger recompilation, currently I'm almost always starting the site with VS debug because it seems to be the only reliable way.

Developer
Jan 10, 2012 at 9:19 PM
randompete wrote:

It happens to me all the time, not just clean instances. F5 in the browser consistently fails to trigger recompilation, currently I'm almost always starting the site with VS debug because it seems to be the only reliable way.

That's exactly the same I'm experiencing.