I'm an old C programmer mostly programming embedded devices with very limited resources.
I have a very simple script that works just fine in C#.
But unfortunately HS3 has a memory leak in C# and RJH strongly recommends converting the script to VB.NET.
But I'm not much of a .NET programmer and there is virtually no error messages on what the script is failing on so I'm hoping someone out there can help me out and see the error in my ways...
I even downloaded Visual Studio and pasted the script into there but the tool is way beyond my desire to learn yet another complex IDE so I am reaching out to you instead... TIA.
The C# script which works but eventually causes HS3 to crash due to the memory leak:
The VB.NET version I tried to convert it into is:
When the VB.NET script runs I get:
VB.Net script exception(0), re-starting: Object reference not set to an instance of an object
a line number would help just a wee little bit or maybe the failing object name???
I have a very simple script that works just fine in C#.
But unfortunately HS3 has a memory leak in C# and RJH strongly recommends converting the script to VB.NET.
But I'm not much of a .NET programmer and there is virtually no error messages on what the script is failing on so I'm hoping someone out there can help me out and see the error in my ways...
I even downloaded Visual Studio and pasted the script into there but the tool is way beyond my desire to learn yet another complex IDE so I am reaching out to you instead... TIA.
The C# script which works but eventually causes HS3 to crash due to the memory leak:
Code:
public object Main(object[] Parms) { string parms = (string)Parms[0]; // get the passed parameter seperated by a comma string P1 = parms.Split(',')[0]; // get the Device ID# string P2 = parms.Split(',')[1]; // get the label for the device string P3 = parms.Split(',')[2]; // get the InitialStateBucket double frtemp; int DeviceRef=Convert.ToInt32(P1); frtemp=hs.DeviceValueEx(DeviceRef); string GrURL = "https://groker.initialstate.com/api/events?accessKey=PutYourKeyHere&bucketKey=" + P3 + "&"+ P2 + "=" + frtemp.ToString(); hs.URLAction(GrURL,"POST", "",""); return 0; }
Code:
Public Function Main(Parms__1 As Object()) As Object Dim parms__2 As String = DirectCast(Parms__1(0), String) ' get the passed parameter seperated by a comma Dim P1 As String = parms__2.Split(","C)(0) ' get the Device ID# Dim P2 As String = parms__2.Split(","C)(1) ' get the label for the device Dim P3 As String = parms__2.Split(","C)(2) ' get the InitialStateBucket Dim frtemp As Double Dim DeviceRef As Integer = Convert.ToInt32(P1) frtemp = hs.DeviceValueEx(DeviceRef) Dim GrURL As String = (Convert.ToString((Convert.ToString("https://groker.initialstate.com/api/events?accessKey=PutYourKeyHere&bucketKey=") & P3) + "&") & P2) + "=" + frtemp.ToString() hs.URLAction(GrURL, "POST", "", "") Return 0 End Function
VB.Net script exception(0), re-starting: Object reference not set to an instance of an object
a line number would help just a wee little bit or maybe the failing object name???
Comment