diff --git a/shadowsocks-csharp/Model/Configuration.cs b/shadowsocks-csharp/Model/Configuration.cs index 5cf6b5348..dedf83e73 100644 --- a/shadowsocks-csharp/Model/Configuration.cs +++ b/shadowsocks-csharp/Model/Configuration.cs @@ -116,6 +116,7 @@ public Configuration() NLogConfig nLogConfig; private static readonly string CONFIG_FILE = "gui-config.json"; + private static readonly string CONFIG_FILE_BAK = "gui-config_bak.json"; #if DEBUG private static readonly NLogConfig.LogLevel verboseLogLevel = NLogConfig.LogLevel.Trace; #else @@ -161,21 +162,34 @@ public static void CheckServer(Server server) public static Configuration Load() { Configuration config; + List errors = new List(); if (File.Exists(CONFIG_FILE)) { - try + + string configContent = File.ReadAllText(CONFIG_FILE); + config = JsonConvert.DeserializeObject(configContent, new JsonSerializerSettings() + { + ObjectCreationHandling = ObjectCreationHandling.Replace, + Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) + { + errors.Add(args.ErrorContext.Error); + }, + }); + if (errors.Count == 0) { - string configContent = File.ReadAllText(CONFIG_FILE); - config = JsonConvert.DeserializeObject(configContent, new JsonSerializerSettings() + try { - ObjectCreationHandling = ObjectCreationHandling.Replace - }); + File.WriteAllText(CONFIG_FILE_BAK, configContent); + } + catch (Exception) { }; return config; } - catch (Exception e) + else { - if (!(e is FileNotFoundException)) - logger.LogUsefulException(e); + foreach(Exception error in errors) + { + logger.LogUsefulException(error); + }; } } config = new Configuration(); diff --git a/shadowsocks-csharp/packages.config b/shadowsocks-csharp/packages.config deleted file mode 100644 index 070ffa21b..000000000 --- a/shadowsocks-csharp/packages.config +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/shadowsocks-csharp/shadowsocks-csharp.csproj b/shadowsocks-csharp/shadowsocks-csharp.csproj index ed1e1b391..bccfca081 100644 --- a/shadowsocks-csharp/shadowsocks-csharp.csproj +++ b/shadowsocks-csharp/shadowsocks-csharp.csproj @@ -1,8 +1,5 @@  - - - Debug AnyCPU @@ -368,7 +365,6 @@ - SettingsSingleFileGenerator Settings.Designer.cs @@ -435,18 +431,116 @@ MSBuild:Compile - + + + 6.0.1 + + + 1.9.0 + + + 2.8.0 + + + 4.1.0 + + + 7.1.1 + + + 6.3.0 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + 1.1.0 + + + 3.14.0 + + + 1.6.0 + + + 12.0.3 + + + 4.7.6 + + + 2.0.5 + + + 12.1.5 + + + 12.1.5 + + + 12.1.5 + + + 1.8.6 + + + 12.1.5 + + + 9.8.1 + + + 4.5.1 + + + 4.3.0 + + + 4.5.4 + + + 4.3.4 + + + 4.5.0 + + + 5.0.0 + + + 4.3.1 + + + 5.0.0 + + + 4.3.1 + + + 4.3.0 + + + 4.3.0 + + + 4.3.2 + + + 4.5.4 + + + 4.5.0 + + + 3.8.0 + + + 2.0.0 + + + 0.16.6 + + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - -