Example #1
0
        public void InitHostEndpoint(string endpointName = null)
        {
            try
            {
                if (SingletonInstance != null)
                {
                    ServiceHost = new ServiceHost(SingletonInstance, new Uri[] { new Uri(ServiceUrl) });
                }
                else
                {
                    ServiceHost = new ServiceHost(ServiceType, new Uri[] { new Uri(ServiceUrl) });
                }

                string endpointUrl = WcfServiceHelper.GetEndpointUrl(ServiceUrl, endpointName);
                ServiceHost.AddServiceEndpoint(ContractType, Binding, endpointUrl);
                ServiceHost.Open();
            }
            catch (Exception ex)
            {
                ServiceHost = null;

                //if (SkipErrorTrace)
                //    Logger.Error("{0}: {1}", ex.GetType().Name, ex.Message);
                //else
                //    Logger.Error(ex, "");
            }
        }