ServiceHostFactory.CreateServiceHost 方法
定义
创建一个 ServiceHost。Creates a ServiceHost.
重载
| CreateServiceHost(String, Uri[]) |
创建具有特定基址的 ServiceHost,并使用指定数据对其进行初始化。Creates a ServiceHost with specific base addresses and initializes it with specified data. |
| CreateServiceHost(Type, Uri[]) |
为具有特定基址的指定类型的服务创建 ServiceHost。Creates a ServiceHost for a specified type of service with a specific base address. |
CreateServiceHost(String, Uri[])
创建具有特定基址的 ServiceHost,并使用指定数据对其进行初始化。Creates a ServiceHost with specific base addresses and initializes it with specified data.
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 实例的由该工厂构建的初始化数据。The initialization data passed to the ServiceHostBase instance being constructed by the factory.
- baseAddresses
- Uri[]
类型为 Array 且包含所承载服务的基址的 Uri。The Array of type Uri that contains the base addresses for the service hosted.
返回
具有特定基址的 ServiceHost。A ServiceHost with specific base addresses.
例外
baseAddress 为 null。baseAddress is null.
未提供宿主上下文,或者 constructorString 为 null 或为空。There is no hosting context provided or constructorString is null or empty.
示例
下面的示例演示如何使用 CreateServiceHost(String, Uri[]) 方法:This example shows how to use the CreateServiceHost(String, Uri[]) method:
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。Creates a ServiceHost for a specified type of service with a specific base address.
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
指定要承载的服务的类型。Specifies the type of service to host.
- baseAddresses
- Uri[]
类型为 Array 且包含所承载服务的基址的 Uri。The Array of type Uri that contains the base addresses for the service hosted.
返回
使用特定基址指定的该类型服务的 ServiceHost。A ServiceHost for the type of service specified with a specific base address.
示例
下面的示例演示如何创建 CreateServiceHost(Type, Uri[]) 方法的重写实现:This example shows how to create an override implementation of the CreateServiceHost(Type, Uri[]) method: