I want to enable my program to load "savegames", and I followed the tutorial on MSDN, but when I run my code, I get the NullReferenceException error. I use an xml file as my savegame data container, and it works, but at this point I have to rebuild my game every time I make some changes to that xml file, and I want to be able to do it during run-time. The xml file is stored in my Content folder. This is the code of my load method:
public void Otvori()
{
IAsyncResult rezultat = device.BeginOpenContainer("OtvaranjeDemo", null, null);
rezultat.AsyncWaitHandle.WaitOne();
container = device.EndOpenContainer(rezultat);
rezultat.AsyncWaitHandle.Close();
if (!container.FileExists(imeDatoteke))
{
container.Dispose();
return;
}
Stream stream = container.OpenFile(imeDatoteke, FileMode.Open);
XmlSerializer serializer = new XmlSerializer(typeof(PostavkeStanice));
PostavkeStanice postavke = (PostavkeStanice)serializer.Deserialize(stream);
stream.Close();
container.Dispose();
}
The compiler throws me the error at this line "IAsyncResult rezultat = device.BeginOpenContainer("OtvaranjeDemo", null, null);"
Since this is a method in a game library, I thought it had something to do with variable definition scope, but I declared the variable in the game wide scope, and I use this method inside the Update method, so that should not be the problem? Do you have any ideas? Thanks