本文整理汇总了C#中ServiceHostBase.Open方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceHostBase.Open方法的具体用法?C# ServiceHostBase.Open怎么用?C# ServiceHostBase.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceHostBase
的用法示例。
在下文中一共展示了ServiceHostBase.Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
const string uriString = "http://localhost:1234/Service1.svc";
_clientFactory = new ClientFactory(uriString);
AppConfigurator.BuildContainer();
_host = new DefaultServiceHostFactory().CreateServiceHost("WcfServiceApplication.Service1", new[] {new Uri(uriString)});
_host.Open();
}
示例2: StartControlService
void StartControlService()
{
controlServiceHost = null;
Exception lastException = null;
for (int iteration = 0; iteration < ListenerConstants.MaxRetries; iteration++)
{
controlServiceGuid = Guid.NewGuid();
string listenerEndPoint = controlServiceGuid.ToString();
try
{
Type contractType;
if (transportType == TransportType.Tcp)
{
contractType = typeof(TcpWorkerProcess);
}
else
{
contractType = typeof(NamedPipeWorkerProcess);
}
ServiceHost typedServiceHost = new ServiceHost(contractType,
Utility.FormatListenerEndpoint(serviceName, listenerEndPoint));
typedServiceHost.ServiceThrottle.MaxConcurrentSessions = ListenerConstants.RegistrationMaxConcurrentSessions;
typedServiceHost.Description.Behaviors.Remove(typeof(ServiceMetadataBehavior));
typedServiceHost.AddServiceEndpoint(typeof(IConnectionRegister),
CreateRegisterBinding(this.transportType), string.Empty);
controlServiceHost = typedServiceHost;
controlServiceHost.Open();
break;
}
catch (CommunicationException exception)
{
if (TD.ServiceStartPipeErrorIsEnabled())
{
Uri formattedUri = Utility.FormatListenerEndpoint(serviceName, listenerEndPoint);
TD.ServiceStartPipeError((formattedUri != null) ? formattedUri.ToString() : string.Empty);
}
if (DiagnosticUtility.ShouldTraceWarning)
{
ListenerTraceUtility.TraceEvent(TraceEventType.Warning, ListenerTraceCode.ServiceStartPipeError, SR.GetString(SR.TraceCodeServiceStartPipeError), this, exception);
}
lastException = exception;
controlServiceHost = null;
}
}
if (controlServiceHost == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
new InvalidOperationException(SR.GetString(SR.ServiceStartErrorEndpoint, this.serviceName),
lastException));
}
}
示例3: EnsureServiceHostCore
void EnsureServiceHostCore ()
{
if (host != null)
return;
//ServiceHost for this not created yet
var baseUri = new Uri (new Uri (HttpContext.Current.Request.Url.GetLeftPart (UriPartial.Authority)), path);
// if (factory_type != null) {
// host = ((ServiceHostFactory) Activator.CreateInstance (factory_type)).CreateServiceHost (type, new Uri [] {baseUri});
// }
// else
host = new ServiceHost (type, baseUri);
host.Extensions.Add (new VirtualPathExtension (baseUri.AbsolutePath));
host.Open ();
}