我试图找到一种方法来启用在多方租用设置中选择的功能。
我尝试在" Orchard.Setup"中设置构造函数中添加IModuleService
。在租户设置其设置后启用所选功能。但是我得到了注射异常。
: '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,
有没有其他方法可以实现这一目标?
答案 0 :(得分:1)
我管理让它工作解析构造函数之外的IFeatureManager:
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);
}