This project is read-only.

service in module inherited from ISingletonDependency lead to TransactionScope nested incorrectly.

Topics: Writing modules
Sep 23, 2011 at 9:02 AM

but only on first call!


what could be wrong?


Server Error in '/OrchardLocal' Application.
TransactionScope nested incorrectly.
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.InvalidOperationException: TransactionScope nested incorrectly.

Source Error:

Line 45:
Line 46:                 Logger.Debug("Final work for transaction being performed");
Line 47:                 _scope.Dispose();
Line 48:                 Logger.Debug("Transaction disposed");
Line 49:             }

Source File: \src\Orchard\Data\TransactionManager.cs    Line: 47

Stack Trace:

[InvalidOperationException: TransactionScope nested incorrectly.]
   System.Transactions.TransactionScope.Dispose() +85286
   Orchard.Data.TransactionManager.System.IDisposable.Dispose() in \src\Orchard\Data\TransactionManager.cs:47
   Autofac.Core.Disposer.Dispose(Boolean disposing) +130
   Autofac.Util.Disposable.Dispose() +78
   Autofac.Core.Lifetime.LifetimeScope.Dispose(Boolean disposing) +45
   Autofac.Util.Disposable.Dispose() +78
   Orchard.Environment.<>c__DisplayClass2.<.ctor>b__0() in \src\Orchard\Environment\WorkContextAccessor.cs:75
   Orchard.Environment.HttpContextScopeImplementation.System.IDisposable.Dispose() in \src\Orchard\Environment\WorkContextAccessor.cs:80
   Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in \src\Orchard\Mvc\Routes\ShellRoute.cs:151
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8862381
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Sep 23, 2011 at 9:09 AM

Something on initialization maybe, seeing this is a singleton?

Sep 23, 2011 at 9:20 AM
Edited Sep 23, 2011 at 9:21 AM

i tried it on different custom modules and it always leads to the same problem. If the service is from ISingletonDependency, and even if the ctor is empty.

Sep 23, 2011 at 8:35 PM

mmh, must be something else about your modules: there are dozens and dozens of implementations of this interface in the system already. Do you have a simple repro we could try?

Sep 24, 2011 at 7:48 PM
Edited Oct 3, 2011 at 2:02 AM

you're right. i installed a clean and propper orchard and it worked in a new module.

so it seems to be something in the referenced modules.

i will keep on searching. its not easy since the exception doesnt tell at all where it appears :(

i'll post what it was as soon as i have it!


i think its not fixed. i use generic interfaces with recordtype as T so i think it has something to do with


and the method sebastian suggested didnt help

betrand i work on a very simple module example,

how can we share?