2012-05-01 150 views
0

我有一个非常简单的服务,在不使用Castle的情况下工作正常(显示其他代码是正确的)。 我改变了我的SVC文件到以下几点:与Castle Windsor注册wcf服务

<%@ ServiceHost Service="Reporting.WebService.ReportingWebService" Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %> 

,并使用XML作为后续注册服务:

<component id="Reporting.WebService.ReportingWebService" 
      service="Reporting.WebService.IReportingWebService, Reporting.WebService" 
      type="Reporting.WebService.ReportingWebService, Reporting.WebService"> 
</component> 

但我收到以下错误:

[InvalidOperationException: Could not find a component with name Reporting.WebService.ReportingWebService, did you forget to register it?] Castle.Facilities.WcfIntegration.WindsorServiceHostFactory`1.CreateServiceHost(String constructorString, Uri[] baseAddresses) 
.... 

任何想法为什么它没有注册? ?

---- ----更新

我这个在Windsor配置:

<facilities> 
    <facility id='wcf' 
      type='Castle.Facilities.WcfIntegration.WcfFacility, 
       Castle.Facilities.WcfIntegration' /> 
</facilities> 

和ReportingWebService在另一个组件implimented。

+0

ReportingWebService与网站或在单独的程序集相同的程序集?你有没有注册WcfFacility? – Bronumski

+0

请参阅问题更新。 – mans

+0

认为你错过了更新的东西:)。没关系,我认为这给了我一个想法。 – Bronumski

回答

2

我看不出导线有什么问题,导致我认为无法找到您的组件或者类型尚未加载。因为您的webservice在另一个程序集中被引用,请确保它在web项目中被引用。或者切换到您的Global.asax中的代码将强制您引用程序集并加载类型:

var container = new WindsorContainer(); 
container.AddFacility<WcfFacility>() 
     .Register(Component.For<IReportingWebService>().ImplementedBy<ReportingWebService>()); 

//Additional wire up 

//If you are using Windsor 3.0 and above then the following is not needed 
DefaultServiceHostFactory.RegisterContainer(container.Kernel); 
+0

谢谢。有没有什么办法可以将我的项目直接引用的配置添加到配置中,但是windows会加载它们并使用它们的obkects? – mans

+0

@ user654019是否意味着您要手动删除该dll并更新配置以使用新的dll。 – Bronumski

+0

是的,我想确保没有对我的服务实现的引用,只引用具有接口定义的项目。 – mans

相关问题