2013-05-06 24 views
0

我开发一个项目,该项目使用Castle Windsor WCF集成工具作为DDD体系结构。有一个容器项目,单个域项目,几个实施项目和一个可执行控制台。依赖关系树可以示出以下等:当代码优化或full-pdb禁用时,Castle Windsor WCF工具无法在发布模式下工作

控制台(EXE) - >容器(温莎) - > {实现 - > DomainInterfaces}

控制台项目调用Container.Bootstrapper.Initialize()和城堡安装搜索该组件在这个方法中。在调试模式下,它可以成功运行,windsor加载所有依赖项并创建WCF服务。当光标进入Initialize时,我可以在Modules窗口中看到新加载的模块。

依赖安装代码如下所示:

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() 
    ); 
} 

问题是在释放模式。我无法为此方法设置断点并且安装程序无法工作,因此没有在“模块”窗口中加载。在发布模式下,只有在未选中代码优化并且在Console项目的项目选项中选中了full-pdb调试信息的情况下才能使用。这是一个已知的问题或错误?

在此先感谢。

+0

我可以想象,对于安装程序的代码进行了优化,从而满足了加载模块的代码不再接他们。用Ildasm检查你的dll的内容。 – Marwijn 2013-05-06 10:53:15

+0

你能告诉我应该检查哪个dll(s)?exe或容器还是实现? – 2013-05-06 16:47:20

+0

尝试检查包含上述安装功能的dll。另外,你可以用NLog在那里放置一条记录线。 (如果代码被优化掉,甚至可能导致问题消失)。 – Marwijn 2013-05-09 07:26:37

回答

2

您应该从不重新安排container安装程序类中的参数。这对我来说是神秘的,它为什么在DEBUG模式下工作。

试试这个:

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()); 
} 
+0

你是对的,我没有看到,但它没有奏效。如果问题的根源在于你的观点,那么它在调试模式下也不起作用。 – 2013-05-07 13:08:07

相关问题