Skip to content

Commit

Permalink
"Value cannot be null. Parameter name: s" bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemrys committed Oct 26, 2017
1 parent d9da54d commit b68d4e7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
18 changes: 12 additions & 6 deletions Vertminer/Main.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 20 additions & 8 deletions Vertminer/P2Pool.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions Vertminer/settings.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b68d4e7

Please sign in to comment.