問題描述
當構建配置為“AnyCPU”或“x64”時,Castle Windsor 無法解決 (Castle Windsor not resolving when build configuration is "AnyCPU" or "x64")
I am using CastleWindsor to register and resolve NHibernate dependencies in a console app and everything works fine as long as I build in x86 platform. But if I change this platform to "AnyCPU" or "x64" it stops resolving the components. Is there a CastleWindsor issue that I am not aware of or am I doing something wrong? Help please. Here is some code that I am using (nothing fancy):
Registration Code:
container.Register(Component.For<ILogger>()
.ImplementedBy<Log4netLog>(),
Component.For<Repository.INHibUnitOfWork>()
.ImplementedBy<Repository.NHibUnitOfWork>().LifestyleTransient()....
Resolve code:
_windsorContainer = new WindsorContainer();
_windsorContainer.Install(FromAssembly.This());
_windsorContainer.Resolve<ISessionFactory>();
Getting an error on the last line. No component for supporting the service ISessionFactory was found. The code runs fine if I build it in x86 configuration.
‑‑‑‑‑
參考解法
方法 1:
I found the problem. One of the project (in the list of 20 projects) was set to build using x86 configuration. After changing its build settings I was able to build and run the project using ANYCPU setting. Thanks for following up and pointing me to the right direction.
(by MuazzamAli、MuazzamAli)