当前位置: 首页>>代码示例>>C#>>正文


C# ServiceHostBase.Open方法代码示例

本文整理汇总了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();
 }
开发者ID:gimmi,项目名称:randomhacking,代码行数:8,代码来源:Service1FunctionalTest.cs

示例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));
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:56,代码来源:SharingService.cs

示例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 ();
		}
开发者ID:kumpera,项目名称:mono,代码行数:16,代码来源:SvcHttpHandler.cs


注:本文中的ServiceHostBase.Open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。