我在 Orchard CMS v1.6 中收到以下错误
“操作对事务状态无效”
在 Orchard CMS 的异步 ApiController 中。但是一旦将异步调用替换为同步调用,它就可以正常工作了。
Orchard 不支持异步 apicontroller 吗?有什么解决方法吗?任何帮助将不胜感激,谢谢。
堆栈跟踪如下,
[TransactionException: The operation is not valid for the state of the transaction.]
System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx, IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions, Transaction atomicTransaction) +53
System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions) +292
NHibernate.Transaction.AdoNetWithDistributedTransactionFactory.EnlistInDistributedTransactionIfNeeded(ISessionImplementor session) +457
NHibernate.Impl.SessionImpl.get_Batcher() +23
NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) +544
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +273
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +205
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +196
[GenericADOException: could not execute query
[ SELECT this_.Id as Id272_3_, this_.Number as Number272_3_, this_.Published as Published272_3_, this_.Latest as Latest272_3_, this_.Data as Data272_3_, this_.ContentItemRecord_id as ContentI6_272_3_, contentite1_.Id as Id271_0_, contentite1_.Data as Data271_0_, contentite1_.ContentType_id as ContentT3_271_0_, sitesettin4_.Id as Id286_1_, sitesettin4_.SiteSalt as SiteSalt286_1_, sitesettin4_.SiteName as SiteName286_1_, sitesettin4_.SuperUser as SuperUser286_1_, sitesettin4_.PageTitleSeparator as PageTitl5_286_1_, sitesettin4_.HomePage as HomePage286_1_, sitesettin4_.SiteCulture as SiteCult7_286_1_, sitesettin4_.ResourceDebugMode as Resource8_286_1_, sitesettin4_.PageSize as PageSize286_1_, sitesettin4_.SiteTimeZone as SiteTim10_286_1_, contenttyp5_.Id as Id273_2_, contenttyp5_.Name as Name273_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id left outer join Settings_SiteSettingsPartRecord sitesettin4_ on contentite1_.Id=sitesettin4_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp5_ on contentite1_.ContentType_id=contenttyp5_.Id WHERE contentite1_.Id = ? and this_.Published = ? ]
Name:cp0 - Value:1 Name:cp1 - Value:True
[SQL: SELECT this_.Id as Id272_3_, this_.Number as Number272_3_, this_.Published as Published272_3_, this_.Latest as Latest272_3_, this_.Data as Data272_3_, this_.ContentItemRecord_id as ContentI6_272_3_, contentite1_.Id as Id271_0_, contentite1_.Data as Data271_0_, contentite1_.ContentType_id as ContentT3_271_0_, sitesettin4_.Id as Id286_1_, sitesettin4_.SiteSalt as SiteSalt286_1_, sitesettin4_.SiteName as SiteName286_1_, sitesettin4_.SuperUser as SuperUser286_1_, sitesettin4_.PageTitleSeparator as PageTitl5_286_1_, sitesettin4_.HomePage as HomePage286_1_, sitesettin4_.SiteCulture as SiteCult7_286_1_, sitesettin4_.ResourceDebugMode as Resource8_286_1_, sitesettin4_.PageSize as PageSize286_1_, sitesettin4_.SiteTimeZone as SiteTim10_286_1_, contenttyp5_.Id as Id273_2_, contenttyp5_.Name as Name273_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id left outer join Settings_SiteSettingsPartRecord sitesettin4_ on contentite1_.Id=sitesettin4_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp5_ on contentite1_.ContentType_id=contenttyp5_.Id WHERE contentite1_.Id = ? and this_.Published = ?]]
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +642
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +23
NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) +60
NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +1039
NHibernate.Impl.CriteriaImpl.List(IList results) +63
NHibernate.Impl.CriteriaImpl.List() +79
Orchard.ContentManagement.DefaultContentManager.GetManyImplementation(QueryHints hints, Action`2 predicate) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\ContentManagement\DefaultContentManager.cs:334
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\ContentManagement\DefaultContentManager.cs:140
Orchard.ContentManagement.ContentGetExtensions.Get(IContentManager manager, Int32 id, VersionOptions options, QueryHints hints) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\ContentManagement\ContentExtensions.cs:160
Orchard.Core.Settings.Services.SiteService.GetSiteSettings() in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard.Web\Core\Settings\Services\SiteService.cs:46
Orchard.Settings.CurrentSiteWorkContext.Get(String name) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\Settings\CurrentSiteWorkContext.cs:13
System.Linq.WhereSelectArrayIterator`2.MoveNext() +111
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +215
Orchard.Environment.WorkContextImplementation.FindResolverForState(String name) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\Environment\WorkContextImplementation.cs:32
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +79
Orchard.Environment.WorkContextImplementation.GetState(String name) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\Environment\WorkContextImplementation.cs:28
Orchard.Roles.Services.RolesBasedAuthorizationService.TryCheckAccess(Permission permission, IUser user, IContent content) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard.Web\Modules\Orchard.Roles\Services\RolesBasedAuthorizationService.cs:50
Orchard.Security.Authorizer.Authorize(Permission permission, IContent content, LocalizedString message) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\Security\Authorizer.cs:72
Orchard.Security.SecurityFilter.OnAuthorization(AuthorizationContext filterContext) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\Security\SecurityFilter.cs:24
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +156
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +714
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +40
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in c:\TeamCity\buildAgent\work\292d2471f57b6038\src\Orchard\Mvc\Routes\ShellRoute.cs:163
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +1799
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +3300
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +1536