codo
09-10-2009 10:28:45
Hello, I need to restart MOGRE engine after changing some graphical settings (like resolution and so on), without killing the whole process and starting everything again. Unfortunately I get the following error after recreating the root object and trying to use LogManager singleton :
Here's the minimalistic code that produces the error:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Mogre.LogManager.LogMessage in d:\cubicalminds\mogreworld\mogre\mogre\src\auto\mogrelogmanager.cpp:line 97
at Wof.Controller.PerformanceTestFramework.Setup in f:\others\WoF\src\Controller\PerformanceTestFramework.cs:line 312
...
Here's the minimalistic code that produces the error:
root = new Root();
LogManager.Singleton.LogMessage("Testing1");
SetupResources("test_resources.cfg");
// In real code I'd like to do some stuff here, loading resources, rendering etc..
root.Shutdown();
root.Dispose();
root = null;
root = new Root();
LogManager.Singleton.LogMessage("Testing2"); // exception!!!
public virtual void SetupResources(string cfgFilename)
{
// Load resource paths from config file
ConfigFile cf = new ConfigFile();
cf.Load(cfgFilename, "\t:=", true);
// Go through all sections & settings in the file
ConfigFile.SectionIterator seci = cf.GetSectionIterator();
String secName, typeName, archName;
// Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too;
while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
}