共用方式為


ServiceHostFactory 類別

定義

在 Managed 裝載環境中提供 ServiceHost 執行個體的處理站,在這個環境中會動態建立主機執行個體以回應傳入訊息。

public ref class ServiceHostFactory : System::ServiceModel::Activation::ServiceHostFactoryBase
public class ServiceHostFactory : System.ServiceModel.Activation.ServiceHostFactoryBase
type ServiceHostFactory = class
    inherit ServiceHostFactoryBase
Public Class ServiceHostFactory
Inherits ServiceHostFactoryBase
繼承
ServiceHostFactory
衍生

範例

這個範例會說明如何使用 ServiceHostFactory 類別:

public class DerivedFactory : ServiceHostFactory
{

    protected override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
    {
        return new DerivedHost( t, baseAddresses );
    }

    //Then in the CreateServiceHost method, we can do all of the
    //things that we can do in a self-hosted case:
    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 Class DerivedFactory
    Inherits ServiceHostFactory

    Protected Overrides Overloads Function CreateServiceHost(ByVal t As Type, ByVal baseAddresses() As Uri) As ServiceHost
        Return New DerivedHost(t, baseAddresses)
    End Function

    'Then in the CreateServiceHost method, we can do all of the
    'things that we can do in a self-hosted case:
    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

End Class

備註

支援動態啟動的 Managed 裝載環境包括網際網路資訊服務 (IIS) 和 Windows Process Activation Service (WAS)。

如果您已實作了 ServiceHost 的自訂衍生,建議您一併實作衍生自 ServiceHostFactory 類別的處理站。

反之,如果您已實作了 ServiceHostBase 的自訂衍生,建議您一併實作直接從 ServiceHostFactoryBase 衍生您處理站的處理站。

建構函式

ServiceHostFactory()

初始化 ServiceHostFactory 類別的新執行個體。

方法

CreateServiceHost(String, Uri[])

建立含有指定基底位址的 ServiceHost 並使用指定資料初始化。

CreateServiceHost(Type, Uri[])

建立含有指定基底位址之指定服務型別的 ServiceHost

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於