Full Version : TargetInvocationException
xmlspawner >>Troubleshooting >>TargetInvocationException


<< Prev | Next >>

roadmaster- 11-22-2006
I dont know if this is a known issue and been fixed with the 2.0 version or not, so please forgive me if it has already been fixed, I did a search for "HasActiveSectors" and the only three message threads that came up had nothing to do with this specific issue.

I got the following Fatal Exception earlier today while trying to startup my server. Im not sure what led up to it, I got a frantic call from one of our Admins while i was at work they couldnt get the server to run without almost a full days revert.

I dont know how our saves got corrupted but it was only one XmlSpawner that had been corrupted.

QUOTE

RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...done (0 errors, 0 warnings)
Scripts: Compiling VB.net scripts...no files found.
Scripts: Verifying...done (4338 items, 1072 mobiles)
World: Loading...done (1124597 items, 38532 mobiles) (62.0 seconds)
Error:
System.Reflection.TargetInvocationException: Exception has been thrown by the ta
rget of an invocation. ---> System.NullReferenceException: Object reference not
set to an instance of an object.
  at Server.Mobiles.XmlSpawner.get_HasActiveSectors()
  at Server.Mobiles.XmlSpawner.Initialize()
  --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlag
s invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean i
sBinderDefault, Assembly caller, Boolean verifyAccess)
  at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlag
s invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean v
erifyAccess)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)
  at Server.ScriptCompiler.Compile(Boolean debug)
  at Server.Core.Main(String[] args)
This exception is fatal, press return to exit


I recently just got back online from having my system drive fail and i didnt have time to accurately debug the HasActiveSectors Property so i just put the following line from the Initialize method, in a try/catch block.

CODE

bool recalc_sectors = spawner.HasActiveSectors;


then in the catch block i put in code to add the specific offending spawner to an arraylist which after the end of the foreach loop, i then ran a for loop to delete the offending spawner.

After adding in the code i Restarted the server then did a WorldSave to give me a save without the bad Spawner.

basically i just did a jury rig fix for now, I know there is still a null reference somewhere in the HasActiveSectors property, I didnt take the time to look too deep into it Due to the fact that my pc is not back up completely yet, but i wanted to let Someone know about it due to the Fatal Exception ie... no crash log, just in case if its never come up before.


roadmaster

ArteGordon- 11-22-2006
I've never seen that one before. What version are you running?

The only possible location that I can see that could produce an exception like that would be at the end of GetActiveSectors. Try adding the code in red to handle

QUOTE

    foreach (Sector s in sectorList)
    {

                    if (s != null && s.Active && s.Players != null && s.Players.Count > 0)
    {

      // confirm that players with the proper access level are present
      foreach (Mobile m in s.Players)
      {

      if (m != null && m.AccessLevel <= SmartSpawnAccessLevel)
      {
        return true;
      }
      }
      _TraceEnd(2);
    }
    seccount++;
    }


roadmaster- 12-09-2006
Im Sorry it took so long to get back to you, after I replaced my System Drive i had to replace my power supply twice befor i realized my SurgeSuppressor had bit the dust, then i had a death in the family, so i havent been up to it much lately. But anyways our Live Server Version is RunUo 1.0.0.

I tried pulling the bad saves from it over to my 2.0 Test Server i have been working on and could not get it to crash with the same problem, after looking at the XmlSpawner2.cs code in the 2 different versions i see there is some additional code in the 2.0 version so maybe its already fixed in 2.0.

Im gonna try and shut down our Live Server to try and test your fix first chance I get to see what happens, Ill give you a yell back as soon as i know something.

thanks for your help.