This project is read-only.


Cannot access a disposed object. Object name: 'TransactionScope'.


This error has been bugging me for quite some time and across different projects. This is the stack trace:

Server Error in '/' Application.

Cannot access a disposed object.
Object name: 'TransactionScope'.

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: Cannot access a disposed object.
Object name: 'TransactionScope'.

Source Error:

Line 41: if (!_cancelled) {
Line 42: Logger.Debug("Marking transaction as complete");
Line 43: _scope.Complete();
Line 44: }
Line 45:

Source File: e:\Overseas 1.5.1\src\Orchard\Data\TransactionManager.cs Line: 43

Stack Trace:

[ObjectDisposedException: Cannot access a disposed object.
Object name: 'TransactionScope'.]
System.Transactions.TransactionScope.Complete() +84955
Orchard.Data.TransactionManager.System.IDisposable.Dispose() in e:\Overseas 1.5.1\src\Orchard\Data\TransactionManager.cs:43
Autofac.Core.Disposer.Dispose(Boolean disposing) +81
Autofac.Util.Disposable.Dispose() +46
Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) +58
Autofac.Util.Disposable.Dispose() +46
Orchard.Environment.DefaultOrchardHost.DisposeShellContext() in e:\Overseas 1.5.1\src\Orchard\Environment\DefaultOrchardHost.cs:202
Orchard.Environment.DefaultOrchardHost.<MonitorExtensions>b__6(AcquireContext1 ctx) in e:\Overseas 1.5.1\src\Orchard\Environment\DefaultOrchardHost.cs:189
2.CreateEntry(TKey k, Func2 acquire) in e:\Overseas 1.5.1\src\Orchard\Caching\Cache.cs:57
2.UpdateEntry(CacheEntry currentEntry, TKey k, Func`2 acquire) in e:\Overseas

file attachments


rdobson wrote Jan 22, 2013 at 10:37 AM

I get this error consistently on Orchard 1.6 when enabling/disabling modules/features, the error originates in a call to _cacheManager.Get("OrchardHost_Extensions",...) in the MonitorExtensions method in DefaultOrchardHost.cs.

rdobson wrote Jan 25, 2013 at 3:34 PM

Here is a patch that resolves the issue for me similar to were the other nearby exceptions are swallowed.

Skelet0r67 wrote Mar 29, 2013 at 7:55 PM

Thanks, this worked for me.