What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

Null reference exception

Ama

New Member
Joined
Jun 6, 2011
Messages
1,171
Reaction score
33
I have a null get a null reference exception occasionally when checking to see if my tank is null. I don't understand why I get the exception b/c I am making the check in an attempt to avoid an exception. It doesn't appear to have any impact on performance, but I would like to eradicate errors from my logs. The line that causes the error is "tank!=null" Here is the code and error:

PHP:
if (tank != null
                && tank.Distance < 60
                && tank.Combat              
                && !tank.HasAura("Beacon of Light")
                && CC("Beacon of Light", tank))
            {
                C("Beacon of Light", tank);
            }


[10:01:27 PM:189] System.NullReferenceException: Object reference not set to an instance of an object.
at HolyPaladinCC.HolyPaladinCC.Self() in Path\HolyPaladinCC.cs:line 227
at HolyPaladinCC.HolyPaladinCC.Combat() in Path\HolyPaladinCC.cs:line 119
at HolyPaladinCC.HolyPaladinCC.Pulse() in Path\HolyPaladinCC.cs:line 60
at Styx.WoWPulsator.Pulse(PulseFlags flags)
at Styx.Logic.BehaviorTree.TreeRoot.Tick()
at Styx.Logic.BehaviorTree.TreeRoot.Run()
 
your always going to get some null errors, particularly when targets die, and despawn, and when changing targets. thats because it can get past your null check and if at that point the wow unit nulls out theres nothing it can do, but null out an cause an exception.
 
Back
Top