ServiceHostFactory.CreateServiceHost 方法

定义

创建一个 ServiceHost

重载

CreateServiceHost(String, Uri[])

创建具有特定基址的 ServiceHost,并使用指定数据对其进行初始化。

CreateServiceHost(Type, Uri[])

为具有特定基址的指定类型的服务创建 ServiceHost

CreateServiceHost(String, Uri[])

创建具有特定基址的 ServiceHost,并使用指定数据对其进行初始化。

public:
 override System::ServiceModel::ServiceHostBase ^ CreateServiceHost(System::String ^ constructorString, cli::array <Uri ^> ^ baseAddresses);
public override System.ServiceModel.ServiceHostBase CreateServiceHost (string constructorString, Uri[] baseAddresses);
override this.CreateServiceHost : string * Uri[] -> System.ServiceModel.ServiceHostBase
Public Overrides Function CreateServiceHost (constructorString As String, baseAddresses As Uri()) As ServiceHostBase

参数

constructorString
String

传递给 ServiceHostBase 实例的由该工厂构建的初始化数据。

baseAddresses
Uri[]

类型为 Array 且包含所承载服务的基址的 Uri

返回

ServiceHostBase

具有特定基址的 ServiceHost

例外

baseAddressnull

未提供宿主上下文,或者 constructorStringnull 或为空。

示例

下面的示例演示如何使用 CreateServiceHost(String, Uri[]) 方法:

public override ServiceHostBase CreateServiceHost
        (string service, Uri[] baseAddresses)

{

    // The service parameter is ignored here because we know our service.
    ServiceHost serviceHost = new ServiceHost(typeof(HelloService),
        baseAddresses);
    return serviceHost;
}
Public Overrides Overloads Function CreateServiceHost(ByVal service As String, ByVal baseAddresses() As Uri) As ServiceHostBase


    ' The service parameter is ignored here because we know our service.
    Dim serviceHost As New ServiceHost(GetType(HelloService), baseAddresses)
    Return serviceHost

End Function

适用于

CreateServiceHost(Type, Uri[])

为具有特定基址的指定类型的服务创建 ServiceHost

protected:
 virtual System::ServiceModel::ServiceHost ^ CreateServiceHost(Type ^ serviceType, cli::array <Uri ^> ^ baseAddresses);
protected virtual System.ServiceModel.ServiceHost CreateServiceHost (Type serviceType, Uri[] baseAddresses);
override this.CreateServiceHost : Type * Uri[] -> System.ServiceModel.ServiceHost
Protected Overridable Function CreateServiceHost (serviceType As Type, baseAddresses As Uri()) As ServiceHost

参数

serviceType
Type

指定要承载的服务的类型。

baseAddresses
Uri[]

类型为 Array 且包含所承载服务的基址的 Uri

返回

ServiceHost

使用特定基址指定的该类型服务的 ServiceHost

示例

下面的示例演示如何创建 CreateServiceHost(Type, Uri[]) 方法的重写实现:

适用于