共用方式為


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[]

型別 ArrayUri,其中包含裝載之服務的基底位址。

傳回

含指定基底位址的 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[]

型別 ArrayUri,其中包含裝載之服務的基底位址。

傳回

由指定基底位址指定之服務型別的 ServiceHost

範例

下列範例會示範如何建立 CreateServiceHost(Type, Uri[]) 方法的覆寫實作:

適用於