Object reference not set to an instance of an object

S

Supra

' 2004
'An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
'Additional information: Object reference not set to an instance of an
object.
Option Explicit On
Option Strict Off

Imports System
Imports System.Text

'Imports System.Net.Dns
'Imports System.Net.Sockets

Namespace PirateChat

Public Class mainPirateChat <==== error occurred in here
Inherits System.Windows.Forms.Form

first server i had problem than another server

the first one is very bad :
eu.undernet.org

the second one is very good
irc.dal.net irc.effnet.net irc.webmaster.com, etc i had no
problem with 3 servers except first server.
i can do small project..... main window application and one class that
can do both servers...but no problem with any servers i can connected
that fine with me...

why the hell is this. public class mainPiratechat...!!!!!
i have 7 mdi forms and 5 classes...
regards
 
S

Supra

did is what i got from debug:
Chicago.IL.US.StarLink.Org 001 djanjo2 :Welcome to the Internet Relay
Network djanjo2
Chicago.IL.US.StarLink.Org 002 djanjo2 :Your host is
Chicago.IL.US.StarLink.Org, running version u2.9.32StarLink2.1
An unhandled exception of type 'System.NullReferenceException' occurred
in system.windows.forms.dll
Additional information: Object reference not set to an instance of an
object.


here is procedure events that caused problem but don't know...(look in
bold area)

Private Sub Netsock_onDataArrival(ByVal Data() As Byte, ByVal
TotalBytes As Integer) Handles Netsock.onDataArrival
Dim inData As String = Netsock.BytestoString(Data)
Dim lData(), C(), CLi As String, tData, CL, a, i As Integer

lData = Split(inData, Chr(10))
tData = UBound(lData) - LBound(lData)

For a = 0 To tData
If Mid(lData(a), 1, 1) = ":" Then
lData(a) = Mid(lData(a), 2)
End If
Next

For CL = 0 To tData
C = Split(lData(CL), " "c)
ReDim Preserve C(32767)
CLi = lData(CL)

' Dim spNick As String(), sNick As String
'Dim strNick As String = CLi
'spNick = strNick.Split("!")
'sNick = spNick(0)

If C(0) = "PING" Then
RaiseEvent onSeverMessage("PONG :" & C(1).Substring(1))
Netsock.SendData(Netsock.StringToBytes("PONG :" &
C(1).Substring(1) & vbCrLf))
End If

If C(0) = "ERROR" Then
Dim int2 As Integer = CLi.IndexOf(":")
CLi = CLi.Substring(int2 + 1)
RaiseEvent onErrorMessage(CLi.ToString)
End If

If C(0) = "NOTICE" Then
Dim int3 As String = CLi.IndexOf(C(0))
CLi = CLi.Substring(C(0).Length + 5)
RaiseEvent onSeverMessage(CLi)
ElseIf C(1) = "NOTICE" And C(2) = "AUTH" Then
Dim int1 As String = CLi.IndexOf(C(0))
CLi = CLi.Substring(C(0).Length)
RaiseEvent onSeverMessage(CLi)
ElseIf C(1) = "NOTICE" And C(2) = Nick Then
Dim int1 As String = CLi.IndexOf(C(0))
CLi = CLi.Substring(C(0).Length + C(1).Length + 2 +
Nick.Length)
RaiseEvent onSeverMessage(CLi)
End If

Dim intI As Integer = Trim(CLi.IndexOf(Nick))
Select Case C(1)
Case "001" To "014", "251" To "272", "372" To "377",
"401", "422", "462", "468", "503"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length)) <===== this is only causing error problem

Case "221"
RaiseEvent onSeverMessage(CLi.Substring(intI + 8))

Case "262"
Case "271"

Case "301", "305" To "307", "305", "311", "312",
"317", "319", "337", "340", "351", "352"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))

Case "302"
Case "303" 'ison
Dim nlform As New frmNotifyLists
'nlform.MdiParent = Me
nlform.UserOnlines(CLi.Substring(intI +
Nick.Length + 2))
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length + 2))
Debug.WriteLine(CLi)
Case "317" 'idle on time

Case "321" 'start of list
Dim frmLvw As New frmLvwLists

' frmLvw.MdiParent = Me
frmLvw.Show()

Case "322" 'Lists
Dim sc As String = C(3)
Dim su As String = C(4)
Dim intI3 As Integer = CLi.IndexOf(":")
Dim st As String = CLi.Substring(intI3 + 1)
Dim frmLvw As New frmLvwLists

frmLvw.AddLists(sc, su, st)
frmLvw.Text = "Lists :" & frmLvw.lvwList.Items.Count
sc = String.Empty : su = String.Empty : st =
String.Empty


Case "324" 'mode
' Case "328"
Case "329"

Case "330"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))


Case "331"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))


' Case "332" 'topic
Case "333" 'set by
Dim szChan As String = C(3)
Dim sznick As String = C(4)
Dim s As String = C(5)
RaiseEvent onSeverMessage(CLi.Substring(szChan &
" set by : " & sznick & " " & AscTime(s) & vbCrLf))


Case "343"
'Stockholm.SE.eu.Undernet.org 333 djanjo #toronto X
Case "367" 'ban on lists
Case "375" 'start of msg

'end list
Case "311", "315", "318", "323", "365", "366",
"368", "376"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))


Case "353" 'name list
Dim n As New frmChannel
Dim b() As String, j As Integer, intI3 As
Integer = CLi.IndexOf(":")
Dim sz As String = CLi.Substring(intI3 + 1)
b = sz.Split(" ")
For j = 0 To b.GetUpperBound(0)
Dim nchan As New frmChannel
nchan.lstNames.Items.Add(b(j))
nchan.lstNames.Sorted = True
nchan.Show()
Debug.WriteLine(b(j))

Next

Case "364"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))


Case "391"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))

Case "421"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))


Case "437"
RaiseEvent onSeverMessage(CLi.Substring(intI +
Nick.Length))


Case "433" ''name already on list
Case "452"
Case "477"
Case "513"

End Select
' End If

Debug.WriteLine(CLi)
CLi = Nothing : C(1) = Nothing : C(2) = Nothing
'String.Empty
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top