2
Vote

DependencyResolutionException from BlogService on Orchard start

description

When the Blogs module is enabled every time Orchard starts (or is recompiled e.g. because of a new module installation) there is a DependencyResolutionException (details below).

I think the cause of this is that BlogService.Get(VersionOptions versionOptions) invokes a ContentManager query, where the List() call in the end runs all handlers registered. In turn this is invoked from BlogPathConstraintUpdator that is an Orchard shell event and calls its Refresh() method on app start, that also calls BlogService.

This is on 1.4.1.

Autofac.Core.DependencyResolutionException was unhandled by user code
Message=No scope with a Tag matching 'work' is visible from the scope in which the instance was requested. This generally indicates that a component registered as per-HTTP request is being reqested by a SingleInstance() component (or a similar scenario.) Under the web integration always request dependencies from the DependencyResolver.Current or ILifetimeScopeProvider.RequestLifetime, never from the container itself.
Source=mscorlib
StackTrace:
Server stack trace: 
   at Autofac.Core.Lifetime.MatchingScopeLifetime.FindScope(ISharingLifetimeScope mostNestedVisibleScope)
   at Autofac.Core.Resolving.InstanceLookup..ctor(IComponentRegistration registration, IResolveOperation context, ISharingLifetimeScope mostNestedVisibleScope, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.AutowiringParameter.<>c__DisplayClass2.<CanSupplyValue>b__0()
   at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.<Execute>b__6()
   at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass4.<>c__DisplayClass6.<RegistrationsFor>b__1(IComponentRegistration cr)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Autofac.Features.Collections.CollectionRegistrationSource.<>c__DisplayClass4.<RegistrationsFor>b__0(IComponentContext c, IEnumerable`1 p)
   at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Registration.ExternalRegistrySource.<>c__DisplayClass8.<RegistrationsFor>b__3(IComponentContext c, IEnumerable`1 p)
   at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p)
   at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Features.LazyDependencies.LazyRegistrationSource.<>c__DisplayClass5`1.<>c__DisplayClass7.<CreateLazyRegistration>b__4()
   at System.Lazy`1.CreateValue()
Exception rethrown at [0]: 
   at System.Lazy`1.get_Value()
   at Orchard.ContentManagement.DefaultContentManager.get_Handlers() in D:\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:line 62
InnerException:

comments

sebastienros wrote May 30, 2012 at 8:03 PM

Please provide a repro

Piedone wrote May 30, 2012 at 10:02 PM

As I can't reproduce it on a clean install apparently it should have something what I have on that specific installation. I'll investigate it and update this issue if I've found the problem.

Piedone wrote Jun 15, 2012 at 2:51 PM

I get a similar exception now on a different site:

NHibernate.QueryException was unhandled by user code
Message=could not resolve property: TitlePartRecord of: Orchard.ContentManagement.Records.ContentItemVersionRecord
Source=NHibernate
StackTrace:
   at NHibernate.Persister.Entity.AbstractPropertyMapping.ToType(String propertyName)
   at NHibernate.Persister.Entity.AbstractEntityPersister.ToType(String propertyName)
   at NHibernate.Loader.Criteria.EntityCriteriaInfoProvider.GetType(String relativePath)
   at NHibernate.Loader.Criteria.CriteriaQueryTranslator.GetPathInfo(String path)
   at NHibernate.Loader.Criteria.CriteriaQueryTranslator.CreateCriteriaEntityNameMap()
   at NHibernate.Loader.Criteria.CriteriaQueryTranslator..ctor(ISessionFactoryImplementor factory, CriteriaImpl criteria, String rootEntityName, String rootSQLAlias)
   at NHibernate.Loader.Criteria.CriteriaLoader..ctor(IOuterJoinLoadable persister, ISessionFactoryImplementor factory, CriteriaImpl rootCriteria, String rootEntityName, IDictionary`2 enabledFilters)
   at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results)
   at NHibernate.Impl.CriteriaImpl.List(IList results)
   at NHibernate.Impl.CriteriaImpl.List[T]()
   at Orchard.ContentManagement.DefaultContentQuery.Slice(Int32 skip, Int32 count) in D:\Orchard\src\Orchard\ContentManagement\DefaultContentQuery.cs:line 146
   at Orchard.ContentManagement.DefaultContentQuery.ContentQuery`1.Orchard.ContentManagement.IContentQuery<T>.List() in D:\Orchard\src\Orchard\ContentManagement\DefaultContentQuery.cs:line 191
   at Orchard.Blogs.Services.BlogService.Get(VersionOptions versionOptions)
   at Orchard.Blogs.Services.BlogService.Get()
   at Orchard.Blogs.Routing.BlogPathConstraintUpdator.Refresh()
   at Orchard.Blogs.Routing.BlogPathConstraintUpdator.Orchard.Environment.IOrchardShellEvents.Activated()
InnerException:

fg_garda wrote Nov 3, 2012 at 11:05 PM

I think the problem is like this: http://orchardtaxonomies.codeplex.com/workitem/60. I wrote a comment on a possible cause.

anoordende wrote Jan 18, 2013 at 9:01 PM

x0r wrote Sep 25, 2013 at 10:24 AM

also happens in 1.7.1