1.4 Setup Failed with Orchard.Security.IMembership not Registered

Topics: Installing Orchard
Mar 24, 2012 at 1:05 AM

Hello Everyne,

I have to start out by saying that Orchard 1.4 is working fine on my localhost but when I attempt to deploy on the host provider I am receiving the following message:

Setup failed: The requested service 'Orchard.Security.IMembership' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

To set up the scenario a bit more, here are the steps that produced this:

  1. Download .zip file: http://orchard.codeplex.com/releases/view/74491
  2. Follow Instructions for Manually installing Orchard zip file: http://docs.orchardproject.net/Documentation/Manually-installing-Orchard-zip-file
    1. I am using the "Default" Orchard Recipe

I fill in all the "Get Started" information and submitted to create the database. The database creates perfect (and from localhost I can confirm that the database connection is functioning properly) but I am returned to the "Get Started" screen with the above error message.

I have checked the "/App_Data/Logs" and there are no error messages recorded in the log file. In short, I am wondering if someone out there can tell me where I can start.  Officially the hosting company I use supports Orchard 1.3.9 so possibly it is some IIS setting that is required?  I have also tried this with a pull of the latest Orchard from the repository and this also has not worked (again, works on localhost).  Thanks for any suggestions (even if they involve something with setup on the server as I belive the hosting company will work with me to have Orchard 1.4 supported). 

Mar 26, 2012 at 1:06 AM

Hello Everyone,

Still looking for some help here if I can get it.  I have done some more digging and I realize that from the error I am receiving, the issue is likely revolving around "Orchard.Environment.WorkContextImplementation" Resolve method (as that method throws this exact type of message when it doesn't function right.  So, I looked for where "IMemebership" was attempting to be "Resolve" and I found an instance in "Orchard.Setup.Services.SetupService".  This seems promising as I am not having the setup complete.  I believe the line that is failing is 181 where it has the following:

private string CreateTenantData(SetupContext context, IWorkContextScope environment) {
     // create superuser
     var membershipService = environment.Resolve<IMembershipService>();
     var user = 
         membershipService.CreateUser(new CreateUserParams(context.AdminUsername, context.AdminPassword,
                                                                  String.Empty, String.Empty, String.Empty,
                                                                  true));

This led me to then check the database and unfortunately, I was wrong above, the table "Orchard_Users_UsersPartRecord" was NOT yet created (a number of other tables were created but this table did not exist).  I am not sure how the order of the migrations are determined but it seems that this table would need to be created prior to getting to the line above that is going to be creating a superuser. Either way, if I am right, I still cannot figure out why the membershipService cannot be resolved.

Look forward to other's thoughts if you don't mind sharing.

Coordinator
Mar 26, 2012 at 1:36 AM

Your install seems to be completely broken for some reason. It's probably easier to just start over.

Mar 26, 2012 at 1:40 AM

Ugh, learning a lot through this research project. 

IMembershipService is only implemented in one spot that I can find and that is in the Orchard.Users module (the actual class is "Orchard.Users.Services.MembershipService"). Being as the database tables were not created for this module it makes me wonder whether the module is enabled / available to "Resolve" IMembershipService and this is what is causing my error. Perhaps I have a failed download and this causing the issue. 

Well, Bertrand you just wrote to tell me the same thing.  I am going to download another copy and give it a shot. My concern is that the hosting company tried the same process and had the same issue (but I will let you know as I can clearly see in SetupService how Orchard.Users is hardcoded to be enabled).  Sometimes having an issue is a great way to learn :)

Mar 26, 2012 at 2:52 AM

Still no go after a clean install but I do now realize there is a first error that is generated:

2012-03-25 18:30:38,896 [13] NHibernate.AdoNet.AbstractBatcher - Could not execute query: SELECT top 2 this_.Id as Id11_0_, this_.SerialNumber as SerialNu2_11_0_ FROM Settings_ShellDescriptorRecord this_ WHERE 1=1
System.Data.SqlClient.SqlException (0x80131904): Invalid object name 'Settings_ShellDescriptorRecord'.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
2012-03-25 18:30:38,912 [13] NHibernate.Util.ADOExceptionReporter - Invalid object name 'Settings_ShellDescriptorRecord'.
2012-03-25 18:30:38,912 [13] NHibernate.Util.ADOExceptionReporter - Invalid object name 'Settings_ShellDescriptorRecord'.

This particular error does not go away until I stop IIS and restart it (then I get the error above (pasted here again):

Setup failed: The requested service 'Orchard.Security.IMembership' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

To be clear, the actual query does not cause an error on the database when I run it now. Therefore, my assumption is that the query is being requested before the database table is built (could be wrong, but seems logical).

I then decided to go ahead and try running using SQL compact edition (just in case) but the same exact thing happens.  Here is a link to a similar conversation but this is a long way in the past: http://orchard.codeplex.com/discussions/260754 - does not seem relevant anymore.

Mar 26, 2012 at 3:28 AM

Another update. When I run the Orchard setup from localhost pointing at the hosted database using source code from the repository the database builds out perfect and the website starts up. When I transfer the App_Data folder over to the hosted website I get the same errors (and nothing starts up).  Tomorrow I am going to try the final test I can think of and that is to bundle up the Source Code and transfer it over to the hosted server to see if it works there.  I tried this real early on and it did not work then so I doubt it will work now.  If it doesn't work, I am convinced there is something wrong somewhere on the hosted environment (though I have no idea what it could be).  Any further suggestions are greatly appreciated.

Coordinator
Mar 26, 2012 at 4:34 AM

Anything unusual in your environment, such as beta versions of anything?

Mar 26, 2012 at 4:47 AM
No, only core the Orchard download unzipped and transferred to host provider.

From: bertrandleroy
Sent: 3/25/2012 11:35 PM
To: Jeff Olmstead
Subject: Re: 1.4 Setup Failed with Orchard.Security.IMembership not Registered [orchard:349850]

From: bertrandleroy

Anything unusual in your environment, such as beta versions of anything?

Coordinator
Mar 26, 2012 at 5:34 AM

Does that host have a special trust level? Do you know of other Orchard sites running there?

Mar 26, 2012 at 10:58 AM
I have four or five Orchard 1.3.X sites running there (they officially have 1.3.9 available and deployable but have not added 1.4.0 yet). I suspected 1.4.0 would work though as I was not aware of any server configuration changes that were required - but perhaps I am wrong on that. Thanks again.

From: bertrandleroy
Sent: 3/26/2012 12:34 AM
To: Jeff Olmstead
Subject: Re: 1.4 Setup Failed with Orchard.Security.IMembership not Registered [orchard:349850]

From: bertrandleroy

Does that host have a special trust level? Do you know of other Orchard sites running there?

Mar 26, 2012 at 4:05 PM

Well, I have transferred the code that works perfect on localhost over to the hosted server, copied over my App_Data folder (which has the connection string and dependencies in it) and am receiving the following error message when I try to access the website:

2012-03-26 07:53:44,499 [20] Orchard.Environment.DefaultOrchardHost - A tenant could not be started: Default
Autofac.Core.DependencyResolutionException: None of the constructors found with 'Orchard.Environment.AutofacUtil.DynamicProxy2.ConstructorFinderWrapper' on type 'Orchard.Security.Authorizer' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Security.IAuthorizationService authorizationService' of constructor 'Void .ctor(Orchard.Security.IAuthorizationService, Orchard.UI.Notify.INotifier, Orchard.IWorkContextAccessor)'.
   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.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.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.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
   at lambda_method(Closure )
   at Orchard.Events.DefaultOrchardEventBus.<NotifyHandlers>d__0.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Orchard.Events.DefaultOrchardEventBus.Notify(String messageName, IDictionary`2 eventData)
   at Orchard.Events.EventsInterceptor.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at IOrchardShellEventsProxyca0f5f6c75e141119f2f5b2270ba41f8.Activated()
   at Orchard.Environment.DefaultOrchardShell.Activate()
   at Orchard.Environment.DefaultOrchardHost.ActivateShell(ShellContext context)
   at Orchard.Environment.DefaultOrchardHost.CreateAndActivateShells()
I am beginning to feel this is outside of my control and that I will have to wait on the host provider. However, I still may be missing something so if you have any input, I will gladly take it.  Mainly, if there are any setup differences on the server that need to be in place, that would be valuable to know as I have not had any trouble with this host provider on 1.3.X version of Orchard. 
Coordinator
Mar 27, 2012 at 5:33 AM

That's a bad deployment most likely. Or bad connection string in settings maybe.

Mar 30, 2012 at 4:30 PM

Well, I know it is not the connection string as it works with Orchard 1.3.9.  It is all very strange and I cannot spend more time on it (will have to wait for the host provider to "officially" support 1.4). 

Out of curiosity, does anyone know of a shared hosting environment that supports Orchard 1.4 AND allows use of Tortoisse Hg / Tortoisse SVN?  I have done a rollout on a dedicated server where these were (obviously) available and it is so nice as compared to FTP.  I have tried Windows Azure (which worked fine with 1.4) but that does not have the source control and is actually slower (observable, not measured) than my current host.  I like my current host but if I cannot get 1.4 working on them (or there is a company with source control) I will be inclined to try this company out.

Thanks

Mar 30, 2012 at 10:10 PM

If you stumble upon this in the future, Windows Azure is actually NOT slower.  Here is the important thing to remember (which I didn't) when setting up Azure - make sure you hosted services, storage accounts, and database are all located in the same region.  Otherwise, you will have a big slowdown.  Once they are all in the same region, everything is great.  Now if only it had source control right inside Azure... Perhaps it does and I have yet to find it.

Mar 31, 2012 at 12:44 AM

Hi jao28!

I might be completely off, but I was having trouble myself this week with updating to 1.4 although not quite the same you've encountered. Anyway, I was facing this exception: The requested service 'Orchard.Security.IMembership' has not been registered. After a long run of trial and error, I found that the App_Data/cache.dat file seems to be causing that. After my update it contained only this:

<?xml version="1.0" encoding="utf-16"?>
<Tenants>
  <Default>53||</Default>
</Tenants>

This seems to be broken. After deleting it and restarting the application (in IIS) my site came back to life :-)

Well, if this doesn't help you, at least I hope it will help someone else (e.g. me in the future).

Cheers!