V
VB Programmer
I am trying to write a telnet emulator. I followed the example code for
EndRead, but when it gets to the last line (in the code below) I get a
NullReferenceException error. Any ideas?
Here's the code:
Private Sub myReadCallBack(ByVal ar As IAsyncResult)
Try
Dim myNetworkStream As NetworkStream = CType(ar.AsyncState,
NetworkStream)
Dim myReadBuffer(1024) As Byte
Dim myCompleteMessage As [String] = ""
Dim numberOfBytesRead As Integer
numberOfBytesRead = myNetworkStream.EndRead(ar) ' ERROR!
The full error: System.NullReferenceException: Object reference not set to
an instance of an object at xxx.Form1.myReadCallBack(IAsyncResult ar).
Any ideas?
Thanks!
EndRead, but when it gets to the last line (in the code below) I get a
NullReferenceException error. Any ideas?
Here's the code:
Private Sub myReadCallBack(ByVal ar As IAsyncResult)
Try
Dim myNetworkStream As NetworkStream = CType(ar.AsyncState,
NetworkStream)
Dim myReadBuffer(1024) As Byte
Dim myCompleteMessage As [String] = ""
Dim numberOfBytesRead As Integer
numberOfBytesRead = myNetworkStream.EndRead(ar) ' ERROR!
The full error: System.NullReferenceException: Object reference not set to
an instance of an object at xxx.Form1.myReadCallBack(IAsyncResult ar).
Any ideas?
Thanks!