I'm trying to register ApplicationContext, but keep getting an error.
My Windsor Installer looks like this:
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
Component.For<ApplicationContext>().ImplementedBy<MyInitializer>(),
Classes.FromThisAssembly().Pick()
.WithService.DefaultInterfaces()
.LifestyleTransient()
);
}
But, when trying to resolve it like this:
public class BootStrapperWindsor
{
public IWindsorContainer BootstrapContainer { get; set; }
public ApplicationContext ApplicationContext
{
get { return BootstrapContainer.Resolve<MyInitializer>(); }
}
public BootStrapperWindsor()
{
BootstrapContainer = new WindsorContainer().Install(FromAssembly.This());
}
}
I get this error when calling ApplicationContext:
"No component for supporting the service MyInitializer was found"
It works fine when I used structuremap and made a similar association in my structuremap registry:
For<ApplicationContext>().Use<MyInitializer>();
But, I can't seem to convert this over to Windsor correctly.
What am I doing wrong that I can't implement the ApplicationContext with MyInitializer?
Also, MyInitializer inherits from ApplicationContext.
container.Resolve< ApplicationContext>()
就是你想要的。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.