From f0b196c8c305f2e5ae1be551a6406a6af15c1473 Mon Sep 17 00:00:00 2001 From: Jacob Zuo Date: Sun, 6 Aug 2017 11:43:25 +0800 Subject: [PATCH] Fix "4.0.4 launch exception" error (PR #1232) --- shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs b/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs index 80637339..778a13e3 100644 --- a/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs +++ b/shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs @@ -48,14 +48,15 @@ namespace Shadowsocks.Util.SystemProxy public static void SetIEProxy(bool enable, bool global, string proxyServer, string pacURL) { Read(); + if (!_userSettings.UserSettingsRecorded) { // record user settings ExecSysproxy("query"); ParseQueryStr(_queryStr); } - string arguments; + string arguments; if (enable) { arguments = global @@ -138,8 +139,10 @@ namespace Shadowsocks.Util.SystemProxy try { string configContent = File.ReadAllText(_userWininetConfigFile); _userSettings = JsonConvert.DeserializeObject(configContent); - } catch (FileNotFoundException) { - _userSettings = new SysproxyConfig(); + } catch(Exception) { + // Suppress all exceptions. finally block will initialize new user config settings. + } finally { + if (_userSettings == null) _userSettings = new SysproxyConfig(); } }