I created a simple web app that has an EasyDAClient and a TextBox. By copying from the QuickStart example my code is:
Protected Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
textBox1.Text = EasyDAClient1.ReadItemValue("", "OPCLabs.KitServer.2", "Demo.Single").ToString()
End Sub
And everything works perfectly. But, if I change my to:
Protected Sub Page_Load(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
EasyDAClient1.SubscribeItem("", "OPCLabs.KitServer.2", "Demo.Single", 10000)
End Sub
Protected Sub EasyDAClient1_ItemChanged(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs) Handles EasyDAClient1.ItemChanged
If e.Exception IsNot Nothing Then
textBox1.Text = "EXCEPTION: " & e.Exception.ToString()
Else
textBox1.Text = e.Vtq.ToString()
End If
End Sub
I end up getting a Null Reference Exception at
at System.Web.HttpApplication.ThreadContext.Enter(Boolean setImpersonationContext)
at System.Web.HttpApplication.OnThreadEnterPrivate(Boolean setImpersonationContext)
at System.Web.AspNetSynchronizationContext.CallCallbackPossiblyUnderLock(SendOrPostCallback callback, Object state)
at System.Web.AspNetSynchronizationContext.CallCallback(SendOrPostCallback callback, Object state)
at System.Web.AspNetSynchronizationContext.Post(SendOrPostCallback callback, Object state)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.RaiseItemChangedEvent(RawEasyDAItemChangedEventArgs itemChangedEventArgs)
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.RaiseEvent(CEasyEvent* Event)
at OpcLabs.EasyOpcRaw.DataAccess.CDAInnerPump.DeliverEvent(CDAInnerPump* , CEasyEvent* Event)
at CEasyAbstractPump.ProcessEventList(CEasyAbstractPump* , CList* EventList)
at CEasyAbstractPump.ExecuteEvents(CEasyAbstractPump* )
at OpcLabs.EasyOpcRaw.DataAccess.RawEasyDAClient.EventsProcess()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Is there something special I need to do when configuring this event handler in my web application?