ServiceHostFactory.CreateServiceHost 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建一个 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 实例的由该工厂构建的初始化数据。
返回
具有特定基址的 ServiceHost。
例外
baseAddress
为 null
。
未提供宿主上下文,或者 constructorString
为 null
或为空。
示例
下面的示例演示如何使用 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
指定要承载的服务的类型。
返回
使用特定基址指定的该类型服务的 ServiceHost。
示例
下面的示例演示如何创建 CreateServiceHost(Type, Uri[]) 方法的重写实现: