I've been trying to figure this out for several hours now with tons of forum searches, and I can't find the answer. I know I'm missing something really simple. My method of programming is old-fashioned, so please don't suggest Tenscripting as a solution
I can't get a reference to the HSP object in my .ASPX pages to work. I've tried every variation of the following code that I can think of. None of them allow me to use something like "hsp.MBSort()" in my webpage. I know the following code won't work as presented, but I've tried just about every variation of what you see. In every case I end up getting one of the following errors:
1) "System.Runtime.Serialization.SerializationException: Type 'Scheduler.PhoneApp' " error when trying to define (Dim or Public) the hsp object. This happens when I "Public hsp as Scheduler.hsp" and then try to set "hsp=hs.GetHSPRef()"
-OR-
2) "System.NullReferenceException: Object reference not set to an instance of an object." on every use of the hsp object (like in a hsp.MBSort() command) -- when I do everything necessary to avoid error #1
The global (Public) reference to the hs object seems to be OK. Can anyone tell me what I need to do so that the hsp object is available to all the sub(routines) in my .ASPX page?
I can't get a reference to the HSP object in my .ASPX pages to work. I've tried every variation of the following code that I can think of. None of them allow me to use something like "hsp.MBSort()" in my webpage. I know the following code won't work as presented, but I've tried just about every variation of what you see. In every case I end up getting one of the following errors:
1) "System.Runtime.Serialization.SerializationException: Type 'Scheduler.PhoneApp' " error when trying to define (Dim or Public) the hsp object. This happens when I "Public hsp as Scheduler.hsp" and then try to set "hsp=hs.GetHSPRef()"
-OR-
2) "System.NullReferenceException: Object reference not set to an instance of an object." on every use of the hsp object (like in a hsp.MBSort() command) -- when I do everything necessary to avoid error #1
The global (Public) reference to the hs object seems to be OK. Can anyone tell me what I need to do so that the hsp object is available to all the sub(routines) in my .ASPX page?
Code:
<%@ Page Language="VB" Debug="true" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="Scheduler" %> <%@ Import Namespace="HomeSeerAPI" %> <%@ Import Namespace="HSCF" %> <script runat="server"> Public hs As Scheduler.hsapplication = Context.Items("Content") Public hsp As Scheduler.hsp Sub Page_Load(Sender As Object, E As EventArgs) Dim hsp As Scheduler.hsp = CType(hs.GetHSPRef(), Scheduler.hsp) hsp = CType(hs.GetHSPRef(), Scheduler.hsp) hsp.MBSort() .... .... End Sub </script>
Comment