Results 1 to 7 of 7

Thread: [2005] System.NullReferenceException: Object reference not set to an instance of an

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    4

    [2005] System.NullReferenceException: Object reference not set to an instance of an

    Hi i am trying to make a proxy for a mmorpg but i get the following errors.

    at TBot.TBot.TCharBot.ParseThingMove(NetworkMessage& msg) in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 1097
    at TBot.TBot.TCharBot.ParseMessage(NetworkMessage& msg) in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 982
    at TBot.TBot.TCharBot.SocketThreadProc() in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 1176
    ParseMessage: System.NullReferenceException: Object reference not set to an instance of an object.
    at TBot.TBot.TCharBot.ParseThingAppear(NetworkMessage& msg) in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 1077
    at TBot.TBot.TCharBot.ParseMessage(NetworkMessage& msg) in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 982
    at TBot.TBot.TCharBot.SocketThreadProc() in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 1176
    Unknown byte 41.
    errors are displayed by this
    Code:
    Me.Trace(("ParseMessage: " & exception1.ToString))
    the errors are occurring in this code
    Code:
            Private Sub SocketThreadProc()
                Dim message1 As New NetworkMessage
                Dim list1 As New ArrayList
                Dim list2 As New ArrayList
                Dim list3 As New ArrayList
                Do While (Me.ClientSocket.Connected AndAlso Me.ServerSocket.Connected)
                    Dim bot1 As TCharBot
                    list1.Clear()
                    list1.Add(Me.ClientSocket)
                    list1.Add(Me.ServerSocket)
                    list3.Clear()
                    list3.Add(Me.ClientSocket)
                    list3.Add(Me.ServerSocket)
                    Socket.Select(list1, list2, list3, 20)
                    If list1.Contains(Me.ClientSocket) Then
                        'send messages from client to server without using xtea
                        message1.ReadStraightFromSocket(Me.ClientSocket)
                        message1.WriteStraightToSocket(Me.ServerSocket)
                    End If
                    If list1.Contains(Me.ServerSocket) Then
                        message1.ReadFromSocket(Me.ServerSocket)
                        Try
                            bot1 = Me
                            SyncLock bot1
                                Me.ParseMessage(message1)
                            End SyncLock
                        Catch exception1 As Exception
                            Me.Trace(("ParseMessage: " & exception1.ToString))
                        End Try
                        message1.WriteToSocket(Me.ClientSocket)
                    End If
                    Try
                        bot1 = Me
                        SyncLock bot1
                            Me.DoBot()
                            Continue Do
                        End SyncLock
                        Continue Do
                    Catch exception2 As Exception
                        Me.Trace(("DoBot: " & exception2.ToString))
                        Continue Do
                    End Try
                Loop
                If Me.ClientSocket.Connected Then
                    Me.ClientSocket.Close()
                End If
                If Me.ServerSocket.Connected Then
                    Me.ServerSocket.Close()
                End If
                If ((Not MyBase.Parent Is Nothing) AndAlso (Not MyBase.Parent.Parent Is Nothing)) Then
                    CType(MyBase.Parent.Parent, TBot).StopTCharBot(Me)
                End If
            End Sub

    how i initialize the parseprocs
    Code:
            Public Sub New(ByVal serverSocket As Socket, ByVal clientSocket As Socket)
                Me.Map = New Map
                Me.ParseProcs = New ParseProc(256  - 1) {}
                Me.LootItems = New Hashtable
                Me.Attackers = New Queue
                Me.CheckBodyPositions = New Queue
                Me.AttackedCreature = 0
                Me.Inventory = New Item(10  - 1) {}
                Me.Waypoints = New ArrayList
                Me.OpenContainers = New Hashtable
                Me.NextDance = 0
                Me.NextFishing = 0
                Me.NextLoot = 0
                Me.NextWayCheck = 0
                Me.ScheduledSteps = 0
                Me.NextWayPoint = Nothing
                Me.rand = New Random
                Me.doBotMsg = New NetworkMessage
                Me.CId = 0
                Me.MapCenterPosInitial = Nothing
                Me.MapCenterPos = New Position
                Me.LightLevel = 0
                Me.InitializeComponent
                Me.ParseProcs(10) = New ParseProc(AddressOf Me.ParseOwnId)
                Me.ParseProcs(11) = New ParseProc(AddressOf Me.ParseBanOptions)
                Me.ParseProcs(30) = New ParseProc(AddressOf Me.ParsePing)
                Me.ParseProcs(50) = New ParseProc(AddressOf Me.ParseReportOption)
                Me.ParseProcs(100) = New ParseProc(AddressOf Me.ParseMapComplete)
                Me.ParseProcs(101) = New ParseProc(AddressOf Me.ParseMapNorth)
                Me.ParseProcs(102) = New ParseProc(AddressOf Me.ParseMapEast)
                Me.ParseProcs(103) = New ParseProc(AddressOf Me.ParseMapSouth)
                Me.ParseProcs(104) = New ParseProc(AddressOf Me.ParseMapWest)
                Me.ParseProcs(105) = New ParseProc(AddressOf Me.ParseMapTile)
                Me.ParseProcs(106) = New ParseProc(AddressOf Me.ParseThingAppear)
                Me.ParseProcs(107) = New ParseProc(AddressOf Me.ParseThingChange)
                Me.ParseProcs(108) = New ParseProc(AddressOf Me.ParseThingRemove)
                Me.ParseProcs(109) = New ParseProc(AddressOf Me.ParseThingMove)
                Me.ParseProcs(110) = New ParseProc(AddressOf Me.ParseContainerOpen)
                Me.ParseProcs(111) = New ParseProc(AddressOf Me.ParseContainerClose)
                Me.ParseProcs(112) = New ParseProc(AddressOf Me.ParseContainerAddItem)
                Me.ParseProcs(113) = New ParseProc(AddressOf Me.ParseContainerChangeItem)
                Me.ParseProcs(114) = New ParseProc(AddressOf Me.ParseContainerRemoveItem)
                Me.ParseProcs(120) = New ParseProc(AddressOf Me.ParseInventoryItem)
                Me.ParseProcs(121) = New ParseProc(AddressOf Me.ParseClearInventoryItem)
                Me.ParseProcs(130) = New ParseProc(AddressOf Me.ParseLightLevel)
                Me.ParseProcs(131) = New ParseProc(AddressOf Me.ParseMagicEffect)
                Me.ParseProcs(132) = New ParseProc(AddressOf Me.ParseAnimatedText)
                Me.ParseProcs(133) = New ParseProc(AddressOf Me.ParseDistanceShoot)
                Me.ParseProcs(134) = New ParseProc(AddressOf Me.ParseBlackBox)
                Me.ParseProcs(140) = New ParseProc(AddressOf Me.ParseCreatureHealth)
                Me.ParseProcs(141) = New ParseProc(AddressOf Me.ParseCreatureLight)
                Me.ParseProcs(142) = New ParseProc(AddressOf Me.ParseCreatureOutfit)
                Me.ParseProcs(143) = New ParseProc(AddressOf Me.ParseCreatureSpeed)
                Me.ParseProcs(144) = New ParseProc(AddressOf Me.ParseCreatureSkull)
                Me.ParseProcs(145) = New ParseProc(AddressOf Me.ParseCreatureShield)
                Me.ParseProcs(160) = New ParseProc(AddressOf Me.ParsePlayerStats)
                Me.ParseProcs(161) = New ParseProc(AddressOf Me.ParsePlayerSkills)
                Me.ParseProcs(162) = New ParseProc(AddressOf Me.ParsePlayerStatus)
                Me.ParseProcs(163) = New ParseProc(AddressOf Me.ParseCancelAttack)
                Me.ParseProcs(170) = New ParseProc(AddressOf Me.ParseCreatureSpeak)
                Me.ParseProcs(172) = New ParseProc(AddressOf Me.ParseOpenChannel)
                Me.ParseProcs(180) = New ParseProc(AddressOf Me.ParseTextMessage)
                Me.ParseProcs(181) = New ParseProc(AddressOf Me.ParseCancelWalk)
                Me.ParseProcs(190) = New ParseProc(AddressOf Me.ParseMapUp)
                Me.ParseProcs(191) = New ParseProc(AddressOf Me.ParseMapDown)
                Me.ParseProcs(210) = New ParseProc(AddressOf Me.ParseVipEntry)
                Me.ParseProcs(211) = New ParseProc(AddressOf Me.ParseCreatureId)
                Me.ServerSocket = serverSocket
                Me.ClientSocket = clientSocket
                Me.SocketThread = New Thread(New ThreadStart(AddressOf Me.SocketThreadProc))
                Me.SocketThread.Start()
    
                'Extra Added By Me
                Me.HP = 0
                Me.MaxHP = 0
                Me.Capacity = 0
                Me.Exp = 0
                Me.Level = 0
                Me.MP = 0
                Me.MaxMP = 0
                Me.MagLvl = 0
                Me.Soulpoints = 0
                Me.Stamina = 0
            End Sub
    Last edited by dudeman501; Mar 18th, 2007 at 07:23 AM.

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    4

    Re: [2005] System.NullReferenceException: Object reference not set to an instance of

    Also in immediate window i get these errors x 100

    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.NullReferenceException' occurred in TBot.exe
    A first chance exception of type 'System.ObjectDisposedException' occurred in System.dll

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    4

    Re: [2005] System.NullReferenceException: Object reference not set to an instance of

    Code:
            Private Sub ParseMessage(ByRef msg As NetworkMessage)
                Do While Not msg.End
                    Dim num1 As Byte = msg.GetByte
                    If (Not Me.ParseProcs(num1) Is Nothing) Then
                        Me.ParseProcs(num1).Invoke(msg)
                        Continue Do
                    End If
                    Me.Trace(("Unknown byte " & num1 & "."))
                    Return
                Loop
            End Sub
    forgot this

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2005] System.NullReferenceException: Object reference not set to an instance of an

    The error is a simple one, but figuring out where it is happening may not be so simple. Does this never happen when you are debugging such that you can narrow it down to a line or two?

    The thing you need to find is an object that you are using without creating a specific instance of the object first. Most of the obvious ones seem to be covered.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    4

    Re: [2005] System.NullReferenceException: Object reference not set to an instance of an

    at TBot.TBot.TCharBot.ParseMessage(NetworkMessage& msg) in C:\Documents and Settings\All Users\Documents\Tibia\TBot\TBot\TCharBot.vb:line 982

    does that link directly to which line the error is occuring on?

    if so it is this line

    " Me.ParseProcs(num1).Invoke(msg)"

  6. #6
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641

    Re: [2005] System.NullReferenceException: Object reference not set to an instance of an

    So you are trying to make a proxy that acts as a 'bot' (Tbot) for an online game?

    Bad karma for you my friend - and if it is WoW (which it looks to be), then I seriously hope your account is banned.
    Martin J Wallace (Slaine)

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] System.NullReferenceException: Object reference not set to an instance of an

    This thread subject is not allowed as its against our AUP and many, if not all, online games.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width