尝试从测试程序集安装所有单独的安装程序时,会抛出一个错误:
"`{"Method not found: 'Castle.MicroKernel.Registration.ComponentRegistration1<!0> Castle.MicroKernel.Registration.ComponentRegistration1.DependsOn(Castle.MicroKernel.Registration.Dependency)'."}`"
尽管代码从控制台应用程序/Windows服务完美运行,而且两个项目的引用是相同的:
Castle.Core
Castle.Facilities.FactorySupport
Castle.Facilities.Logging
Castle.Facilities.QuartzIntegration
Castle.Services.Logging.NLogIntegration
Castle.Windsor
有人知道为什么测试程序集调用建立温莎容器的方式会出现问题吗?
this.Container = new WindsorContainer(new XmlInterpreter())
.Install(FromAssembly.Named("Assembly.WindowsService",
new CustomWindsorInstallerFactory()));
在任何引用“DependsOn”方法的代码上失败,例如:
container.Register(
Component
.For<ISftpRepository, ISftpFileStoreRepository, AbstractSftpFileStoreRepository>()
.ImplementedBy<ConcreteSftpRepository>()
.Properties(PropertyFilter.IgnoreAll)
.DependsOn(
Dependency.OnConfigValue("host", config.Host),
或者:
.ConfigureFor<QuartzJob>(
x =>
x.DependsOn(ServiceOverride.ForKey<IService>().Eq("intraService")))
注意:请注意,在运行单元测试时,所有安装类都可以在主应用程序下正常工作,这仅是情境案例。
感谢任何帮助。