From efd7fbd3c08975a3dfc2a61a1d5d59a079c3f9b6 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 28 Jul 2016 18:07:26 +0200 Subject: [PATCH] Style fixes + move ServiceHost to try block --- ArchiSteamFarm/GlobalConfig.cs | 2 +- ArchiSteamFarm/WCF.cs | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ArchiSteamFarm/GlobalConfig.cs b/ArchiSteamFarm/GlobalConfig.cs index 4cbbb3f4b..ae589eeea 100644 --- a/ArchiSteamFarm/GlobalConfig.cs +++ b/ArchiSteamFarm/GlobalConfig.cs @@ -105,7 +105,7 @@ namespace ArchiSteamFarm { [JsonProperty(Required = Required.DisallowNull)] internal readonly ushort WCFPort = DefaultWCFPort; - [JsonProperty(Required = Required.DisallowNull)] + [JsonProperty(Required = Required.DisallowNull)] internal readonly bool Statistics = true; [JsonProperty(Required = Required.DisallowNull)] diff --git a/ArchiSteamFarm/WCF.cs b/ArchiSteamFarm/WCF.cs index 6dfd570f9..59c755d85 100644 --- a/ArchiSteamFarm/WCF.cs +++ b/ArchiSteamFarm/WCF.cs @@ -88,21 +88,18 @@ namespace ArchiSteamFarm { } Logging.LogGenericInfo("Starting WCF server..."); - ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); - ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior - { - HttpGetEnabled = true - }); - ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, - MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); - ServiceHost.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), string.Empty); try { + ServiceHost = new ServiceHost(typeof(WCF), new Uri(URL)); + + ServiceHost.Description.Behaviors.Add(new ServiceMetadataBehavior { + HttpGetEnabled = true + }); + + ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpBinding(), "mex"); + ServiceHost.AddServiceEndpoint(typeof(IWCF), new BasicHttpBinding(), string.Empty); + ServiceHost.Open(); - } catch (AddressAccessDeniedException) { - Logging.LogGenericWarning("WCF service could not be started because of AddressAccessDeniedException"); - Logging.LogGenericWarning("If you want to use WCF service provided by ASF, consider starting ASF as administrator, or giving proper permissions"); - return; } catch (Exception e) { Logging.LogGenericException(e); return;