Регистрация службы wcf с замком Виндзор
У меня очень простой сервис, который отлично работает, когда не используется Castle (который показывает, что другие коды верны). Я изменил свой файл SVC на следующее:
<%@ 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)
....
Есть идеи, почему он не зарегистрирован??
----Обновить ----
У меня это в виндзорской конфигурации:
<facilities>
<facility id='wcf'
type='Castle.Facilities.WcfIntegration.WcfFacility,
Castle.Facilities.WcfIntegration' />
</facilities>
и ReportingWebService внедряется в другую сборку.
1 ответ
Я не вижу ничего плохого в подключенном проводе, что наводит меня на мысль, что либо он не может найти вашу сборку, либо, возможно, тип не был загружен. Поскольку на ваш веб-сервис ссылаются в другой сборке, убедитесь, что на него ссылаются в веб-проекте. В качестве альтернативы переключитесь на подключение к вашему 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);