0

I develop a project that uses Castle Windsor WCF Integration Facility as DDD architecture. There are a single container project, single domain project, several implementation projects and an executable console. Dependency tree can be shown like below:

Console(exe) -> Container(windsor) -> { Implementations -> DomainInterfaces }

Console project invokes Container.Bootstrapper.Initialize() and castle installers search this assembly in this method. In debug mode, it works successfully, windsor loads all dependencies and creates WCF service. When cursor enters into Initialize, I can see newly loaded modules in Modules window.

Dependency installation code is shown below:

public void Install(IWindsorContainer container, IConfigurationStore store)
{
    container = new WindsorContainer().AddFacility<WcfFacility>()
    .Register
    (
        Component.For<IDataProvider>().Instance(new DataProvider(s_DataConfigurationElement)).LifeStyle.Singleton,
        Component.For<IUserRepository>().ImplementedBy<UserRepository>().LifeStyle.Singleton,
        Component.For<IDomainManager>().ImplementedBy<DomainManager>().LifeStyle.Singleton,
        Component.For<IGateway>().ImplementedBy<Gateway>().LifeStyle.PerThread.AsWcfService()
    );
}

Problem is in release mode. I could't set breakpoint to this method and installers couldn't work, so nothing was loaded in Modules Window. In release mode, it works only if code optimization is unchecked and full-pdb debug info is checked in the project options of Console project. Is this a known issue or bug?

Thanks in advance.

eulerfx
  • 36,769
  • 7
  • 61
  • 83
Onur Gazioğlu
  • 501
  • 2
  • 12
  • I can image that the code for the installers is optimized away so that the code for loading the modules is no longer picking them up. Check the content of your dll's with Ildasm. – Marwijn May 06 '13 at 10:53
  • can you tell me that which dll(s) should I check?Exe or container or implementations? – Onur Gazioğlu May 06 '13 at 16:47
  • try checking the dll which contains the install function above. Alternative you could put a logging line in there with NLog. (If the code is optimized away that could even make the problem go away). – Marwijn May 09 '13 at 07:26

1 Answers1

2

You should never reassign container parameter in installer class. It is mystery for me, why it worked in DEBUG mode.

Try this instead:

public void Install(IWindsorContainer container, IConfigurationStore store) {
    container.AddFacility<WcfFacility>();
    container.Register(
        Component.For<IDataProvider>().Instance(new DataProvider(s_DataConfigurationElement)),
        Component.For<IUserRepository>().ImplementedBy<UserRepository>(),
        Component.For<IDomainManager>().ImplementedBy<DomainManager>(),
        Component.For<IGateway>().ImplementedBy<Gateway>().AsWcfService());
}
Aleš Roubíček
  • 5,198
  • 27
  • 29
  • you are right, I had not saw, but it hasn't worked. If the source of problem is your point, it doesn't work also in debug mode. – Onur Gazioğlu May 07 '13 at 13:08