Hashtable Loading Data Problem

I am saving (successfully) some data in a hashtable using:

userData.Add(personScript.gameObject.name+".personId" ,personScript.personId);
	print("YES Saved:"+personScript.gameObject.name+".personId="+personScript.personId);//saves correctly

but when I come to load this specific line (and only this line)…

personScript.suspectIdString=loadedData[personScript.gameObject.name+".suspectIdString"];
	//this one works fine
	print("Value Before:"+personScript.suspectId);//print correctly as an int
	personScript.suspectId=loadedData[personScript.gameObject.name+".suspectId"];//cant seem to load this
	print("Never gets here-CRASH");

it bombs out. Other data in the same load call seems to work (notably strings). ANy idea why this might be happening?

Has anyone got any hashtable tips?

I ran some further tests on this and it looks like the hastable contains the variable right up until the point at which I try to retrieve the daved saved data. I get the error…

NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.CheckNumericPromotion (IConvertible convertible)
Boo.Lang.Runtime.RuntimeServices.CheckNumericPromotion (System.Object value)
Boo.Lang.Runtime.RuntimeServices.UnboxInt32 (System.Object value)
RemoteSaveManager+Load_Person$177+$.MoveNext () (at Assets\MIHT_Assets\MIHT_Scripts\SaveManager\RemoteSaveManager.js:484)

…but then when I look through the hashtable (using hastable.COntains) the variable IS there. So why doesnt it load it???

Anyone know??

Somebody help…pleaaase! :slight_smile:

The hashtable will return null when you attempt to retrieve a key that isn’t there. If you then try to use that null value as an object reference, you get the null reference error. You will also have problems if you try to assign a null value to an integer or other variable type. The most likely problem here is that you are not spelling or constructing the key name correctly. It’s worth checking this out (and make sure the keys have the same upper/lower case) but if you get nowhere, perhaps you can post the code sections where the problematic key is added and retrieved.