private ServiceHost StartServiceEndpoint(object serviceInstance, ServiceEndpointAddress serviceAddress) { AnchorUtil.ThrowOnNullArgument(serviceInstance, "serviceInstance"); ServiceHost result; try { ServiceHost serviceHost = new ServiceHost(serviceInstance, serviceAddress.GetBaseUris()); serviceHost.AddDefaultEndpoints(); this.logger.Log(MigrationEventType.Verbose, "Opening service host for {0}, with service type {1} and namespace {2}.", new object[] { serviceHost.Description.Name, serviceHost.Description.ServiceType.FullName, serviceHost.Description.Namespace }); ServiceDebugBehavior serviceDebugBehavior = serviceHost.Description.Behaviors.Find <ServiceDebugBehavior>(); if (serviceDebugBehavior == null) { serviceDebugBehavior = new ServiceDebugBehavior(); serviceHost.Description.Behaviors.Add(serviceDebugBehavior); } serviceDebugBehavior.IncludeExceptionDetailInFaults = true; foreach (System.ServiceModel.Description.ServiceEndpoint serviceEndpoint in serviceHost.Description.Endpoints) { NetTcpBinding netTcpBinding = serviceEndpoint.Binding as NetTcpBinding; if (netTcpBinding != null) { netTcpBinding.MaxReceivedMessageSize = 10485760L; netTcpBinding.ReceiveTimeout = TimeSpan.FromMinutes(10.0); netTcpBinding.SendTimeout = TimeSpan.FromMinutes(10.0); } this.logger.LogVerbose("Using binging: {0} ({1})", new object[] { serviceEndpoint.Binding.Name, serviceEndpoint.Binding.MessageVersion }); LoadBalanceUtils.UpdateAndLogServiceEndpoint(this.logger, serviceEndpoint); } serviceHost.Open(); result = serviceHost; } catch (Exception exception) { this.logger.LogError(exception, "Failed to register endpoint for service {0}", new object[] { serviceInstance.GetType().Name }); throw; } return(result); }
protected internal static IDisposable SetEndpointAddress(ServiceEndpointAddress endpointAddress) { return(LoadBalanceService.EndpointAddressHook.SetTestHook(endpointAddress)); }