Orchard Multi-tenenacy Enable features selected .

70 views Asked by At

I'm trying to find a way to enable features that has been selected on the Multi-tenancy Setup .

I tried to add the IModuleService in the Setup Constructor in "Orchard.Setup" to enable selected features once the tenant has set up his settings. but i got an injection exception .

: 'None of the constructors found with 'Orchard.Environment.AutofacUtil.DynamicProxy2.ConstructorFinderWrapper' on type 'Orchard.Setup.Controllers.SetupController' can be invoked with the available services and parameters:
Cannot resolve parameter 'Orchard.Modules.Services.IModuleService Services' of constructor 'Void .ctor(Orchard.UI.Notify.INotifier, Orchard.Setup.Services.ISetupService, 

is there any other ways to achieve this ?

1

There are 1 answers

0
buff On BEST ANSWER

I Managed to get it working Resolving the IFeatureManager outside the constructor :

        using (var environment = _orchardHost.CreateStandaloneEnvironment(shellSettings))
        {
            var FeatureManager = environment.Resolve<IFeatureManager>();
            var FeatureIds= FeatureManager.GetAvailableFeatures().Where(x => x.Name == "MyModule").Select(x => x.Id);
            FeatureManager.EnableFeatures(FeatureIds);
        }