From b68d4e7757f9d7c7aa50ed8b2198afea07c3f113 Mon Sep 17 00:00:00 2001 From: Zemrys Date: Thu, 26 Oct 2017 08:38:55 -0400 Subject: [PATCH] "Value cannot be null. Parameter name: s" bugfix --- Vertminer/Main.vb | 18 ++++++++++++------ Vertminer/P2Pool.vb | 28 ++++++++++++++++++++-------- Vertminer/settings.vb | 7 +++++-- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Vertminer/Main.vb b/Vertminer/Main.vb index dd3511c..7a05b2e 100755 --- a/Vertminer/Main.vb +++ b/Vertminer/Main.vb @@ -751,7 +751,9 @@ Public Class Main Try Dim settingsJSON As Settings_JSON = New Settings_JSON() Dim settings_string As String = File.ReadAllText(settingsfile) - settingsJSON = JSONConverter.Deserialize(Of Settings_JSON)(settings_string) + If Not String.IsNullOrEmpty(settings_string) Then + settingsJSON = JSONConverter.Deserialize(Of Settings_JSON)(settings_string) + End If appdata = settingsJSON.appdata start_minimized = settingsJSON.start_minimized start_with_windows = settingsJSON.start_with_windows @@ -866,8 +868,10 @@ Public Class Main Next End If Dim jsonstring = JSONConverter.Serialize(newjson) - Dim jsonFormatted As String = JValue.Parse(jsonstring).ToString(Formatting.Indented) - File.WriteAllText(settingsfile, jsonFormatted) + If Not String.IsNullOrEmpty(jsonstring) Then + Dim jsonFormatted As String = JValue.Parse(jsonstring).ToString(Formatting.Indented) + File.WriteAllText(settingsfile, jsonFormatted) + End If Catch ex As IOException _logger.LogError(ex) Finally @@ -990,7 +994,7 @@ Public Class Main workers.Clear() passwords.Clear() Dim newjson - Dim jsonstring As String + Dim jsonstring As String = "" For Each row As DataGridViewRow In DataGridView1.Rows Dim chk As DataGridViewCheckBoxCell = row.Cells(DataGridView1.Columns(0).Name) If chk.Value IsNot Nothing AndAlso chk.Value = True Then 'add AndAlso chk.Value = True to only add pools that are checked @@ -1054,8 +1058,10 @@ Public Class Main newjson.intensity = mining_intensity jsonstring = JSONConverter.Serialize(newjson) End If - Dim jsonFormatted As String = JValue.Parse(jsonstring).ToString(Formatting.Indented) - File.WriteAllText(minersettingsfile, jsonFormatted) + If Not String.IsNullOrEmpty(jsonstring) Then + Dim jsonFormatted As String = JValue.Parse(jsonstring).ToString(Formatting.Indented) + File.WriteAllText(minersettingsfile, jsonFormatted) + End If Catch ex As Exception MsgBox(ex.Message) _logger.LogError(ex) diff --git a/Vertminer/P2Pool.vb b/Vertminer/P2Pool.vb index 21b77cb..d72df4e 100755 --- a/Vertminer/P2Pool.vb +++ b/Vertminer/P2Pool.vb @@ -148,13 +148,17 @@ Public Class P2Pool Try Dim p2pool_api As Object = Nothing Dim newjson As String = "" + Dim jsonformatted As String = "" Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(host) Dim response As System.Net.HttpWebResponse = request.GetResponse() Using sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) p2pool_api = p2pool_api & sr.ReadLine End Using - Dim jsonformatted As String = JValue.Parse(p2pool_api).ToString(Formatting.Indented) - File.WriteAllText(scannerfolder & "\network1.json", jsonformatted) + If Not String.IsNullOrEmpty(p2pool_api) Then + jsonformatted = JValue.Parse(p2pool_api).ToString(Formatting.Indented) + File.WriteAllText(scannerfolder & "\network1.json", jsonformatted) + jsonformatted = "" + End If System.Threading.Thread.Sleep(100) p2pool_api = File.ReadAllLines(scannerfolder & "\network1.json") For Each line As String In p2pool_api @@ -168,8 +172,10 @@ Public Class P2Pool newjson = newjson.Insert(1, Environment.NewLine & """nodes"":[") newjson = newjson.Insert(newjson.Length - 1, "]") newjson = newjson.Replace(" ", "").Replace(vbCr, "").Replace(vbLf, "").Trim - jsonformatted = JValue.Parse(newjson).ToString(Formatting.Indented) - File.WriteAllText(scannerfolder & "\network1.json", jsonformatted) + If Not String.IsNullOrEmpty(newjson) Then + jsonformatted = JValue.Parse(newjson).ToString(Formatting.Indented) + File.WriteAllText(scannerfolder & "\network1.json", jsonformatted) + End If scanner1 = JSONConverter.Deserialize(Of Node_JSON)(jsonformatted) Dim count = scanner1.nodes.Count - 1 Dim chk As New DataGridViewCheckBoxColumn() @@ -244,13 +250,17 @@ Public Class P2Pool Try Dim p2pool_api As Object = Nothing Dim newjson As String = "" + Dim jsonformatted As String = "" Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(host) Dim response As System.Net.HttpWebResponse = request.GetResponse() Using sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) p2pool_api = p2pool_api & sr.ReadLine End Using - Dim jsonformatted As String = JValue.Parse(p2pool_api).ToString(Formatting.Indented) - File.WriteAllText(scannerfolder & "\network2.json", jsonformatted) + If Not String.IsNullOrEmpty(p2pool_api) Then + jsonformatted = JValue.Parse(p2pool_api).ToString(Formatting.Indented) + File.WriteAllText(scannerfolder & "\network2.json", jsonformatted) + jsonformatted = "" + End If System.Threading.Thread.Sleep(100) p2pool_api = File.ReadAllLines(scannerfolder & "\network2.json") For Each line As String In p2pool_api @@ -264,8 +274,10 @@ Public Class P2Pool newjson = newjson.Insert(1, Environment.NewLine & """nodes"":[") newjson = newjson.Insert(newjson.Length - 1, "]") newjson = newjson.Replace(" ", "").Replace(vbCr, "").Replace(vbLf, "").Trim - jsonformatted = JValue.Parse(newjson).ToString(Formatting.Indented) - File.WriteAllText(scannerfolder & "\network2.json", jsonformatted) + If Not String.IsNullOrEmpty(newjson) Then + jsonformatted = JValue.Parse(newjson).ToString(Formatting.Indented) + File.WriteAllText(scannerfolder & "\network2.json", jsonformatted) + End If scanner2 = New Node_JSON() scanner2 = JSONConverter.Deserialize(Of Node_JSON)(jsonformatted) Dim count = scanner2.nodes.Count - 1 diff --git a/Vertminer/settings.vb b/Vertminer/settings.vb index c9a5c0b..93aac4d 100755 --- a/Vertminer/settings.vb +++ b/Vertminer/settings.vb @@ -203,6 +203,7 @@ Public Class settings newjson.keep_miner_alive = "false" newjson.keep_p2pool_alive = "false" newjson.use_upnp = "false" + newjson.show_cli = "false" newjson.p2pool_network = "1" newjson.p2pool_node_fee = "0" newjson.p2pool_donation = "1" @@ -237,8 +238,10 @@ Public Class settings Next End If Dim jsonstring = JSONConverter.Serialize(newjson) - Dim jsonFormatted As String = JValue.Parse(jsonstring).ToString(Formatting.Indented) - File.WriteAllText(settingsfile, jsonFormatted) + If Not String.IsNullOrEmpty(jsonstring) Then + Dim jsonFormatted As String = JValue.Parse(jsonstring).ToString(Formatting.Indented) + File.WriteAllText(settingsfile, jsonFormatted) + End If Catch ex As IOException _logger.LogError(ex) Finally