我自托管了几个服务,在这些服务中我注册了服务:
host = new ServiceHost(typeof(MyService));
host.Open();在幕后,wcf通过默认构造函数实例化我的服务。
当我自托管时,是否可以使用Castle Windsor的WCF集成工具让WCF调用Windsor来创建服务?
该示例显示了IIS托管服务,其中MyService.svc文件的第1行如下所示:
<%@ServiceHost language=c# Debug="true"
Service="Microsoft.ServiceModel.Samples.CalculatorService"
Factory=WindsorServiceHostFactory%>其中wcf大概使用工厂来实例化服务实例。
发布于 2010-03-25 05:11:54
这可能会有所帮助:
How to host a WCF service that uses Castle Windsor in a Windows Service
但如果不是,我建议你尝试在the castle user forum上询问。
发布于 2014-10-06 20:09:49
在Castle 3.0中,实现这一点的方法如下:
// setup IoC, including registering the WcfFacility from Castle.WcfIntegrationFacility
container.AddFacility<WcfFacility>();
// and all other registrations you need然后,假设您的app.config中有必要的详细信息,或者可以使用默认值:
// T is an interface with a backing service implementation registered in your IoC
public static ServiceHostBase StartHostService<T>(string serviceUrl)
{
var assemblyQualifiedName = typeof(T).AssemblyQualifiedName;
var serviceHost = new DefaultServiceHostFactory()
.CreateServiceHost(assemblyQualifiedName, new[] { new Uri(serviceUrl) });
serviceHost.Open();
return serviceHost;
}https://stackoverflow.com/questions/2511185
复制相似问题