Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF集成设施和自托管服务_Wcf_Castle Windsor - Fatal编程技术网

WCF集成设施和自托管服务

WCF集成设施和自托管服务,wcf,castle-windsor,Wcf,Castle Windsor,我正在自托管多个服务,我这样做是为了注册服务: host = new ServiceHost(typeof(MyService)); host.Open(); 在幕后,wcf通过默认构造函数实例化我的服务 当我自托管时,是否可以使用Castle Windsor的WCF集成设施让WCF调用Windsor创建服务 该示例显示了IIS托管的服务,其中MyService.svc文件的第1行如下所示: <%@ServiceHost language=c# Debug="true" Se

我正在自托管多个服务,我这样做是为了注册服务:

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可能使用工厂来实例化服务实例。

这可能会有所帮助:


但如果不是,我建议你试着问一下

对于Castle 3.0,实现这一点的方法如下:

// setup IoC, including registering the WcfFacility from Castle.WcfIntegrationFacility
container.AddFacility<WcfFacility>();
// and all other registrations you need

实际上,工厂用于实例化
服务主机的一个实例。然后,该主机将根据需要创建服务类实例来处理传入的RequestsHanks,这几乎正是我所需要的。杰出的
// 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;
}