diff --git a/shadowsocks-csharp/Controller/System/AutoStartup.cs b/shadowsocks-csharp/Controller/System/AutoStartup.cs index 86e1af04..688ff362 100644 --- a/shadowsocks-csharp/Controller/System/AutoStartup.cs +++ b/shadowsocks-csharp/Controller/System/AutoStartup.cs @@ -39,8 +39,10 @@ namespace Shadowsocks.Controller { if (runKey != null) { - try { runKey.Close(); } - catch (Exception e) + try { + runKey.Close(); + runKey.Dispose(); + } catch (Exception e) { Logging.LogUsefulException(e); } } } @@ -84,8 +86,10 @@ namespace Shadowsocks.Controller { if (runKey != null) { - try { runKey.Close(); } - catch (Exception e) + try { + runKey.Close(); + runKey.Dispose(); + } catch (Exception e) { Logging.LogUsefulException(e); } } } diff --git a/shadowsocks-csharp/Controller/System/SystemProxy.cs b/shadowsocks-csharp/Controller/System/SystemProxy.cs index 74393986..b53f4a65 100644 --- a/shadowsocks-csharp/Controller/System/SystemProxy.cs +++ b/shadowsocks-csharp/Controller/System/SystemProxy.cs @@ -84,8 +84,10 @@ namespace Shadowsocks.Controller MessageBox.Show( I18N.GetString( "Failed to update registry" ) ); } finally { if ( registry != null ) { - try { registry.Close(); } - catch (Exception e) + try { + registry.Close(); + registry.Dispose(); + } catch (Exception e) { Logging.LogUsefulException(e); } } } @@ -119,8 +121,10 @@ namespace Shadowsocks.Controller Logging.LogUsefulException( e ); } finally { if ( registry != null ) { - try { registry.Close(); } - catch (Exception e) + try { + registry.Close(); + registry.Dispose(); + } catch (Exception e) { Logging.LogUsefulException(e); } } } @@ -165,8 +169,10 @@ namespace Shadowsocks.Controller } finally { if (registry != null) { - try { registry.Close(); } - catch (Exception e) + try { + registry.Close(); + registry.Dispose(); + } catch (Exception e) { Logging.LogUsefulException(e); } } }