Fighting an AccessViolationExcption

iso

18-10-2009 18:18:19

Hello!

I've been working on a 3D editor famework using MOgre for a year. Yesterday, I updated the MOgre to 1.6.4 and returned to an error I've been fighting since the beginning. I bind the Ogre rendering windows to Windows.Forms following tutorial 6. There are several ogre windows used at once wrapped in DockPanel suite. The problem is, that just before closing the application (during the final garbage collection) an AccessViolationExcption was undandled without any details is thrown! It is an OpenGL specific problem, with DX no exception is thrown. Here are the details:

Someone advised me to use a main dummy window to retain context. It's my top window. The Mogre initialization code:

mRoot = new Root("");
mRoot.LoadPlugin(AbsoluteBinPath + "libraries\\RenderSystem_GL.dll");
mRoot.LoadPlugin(AbsoluteBinPath + "libraries\\Plugin_BSPSceneManager.dll");
mRoot.LoadPlugin(AbsoluteBinPath + "libraries\\Plugin_OctreeSceneManager.dll");
mRoot.AddResourceLocation(AbsoluteBinPath + "media\\OgreCore.zip", "Zip", "Bootstrap");

RenderSystem rs = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem");
mRoot.RenderSystem = rs;
rs.SetConfigOption("Full Screen", "No");
rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour");

mRoot.Initialise(false);

NameValuePairList misc = new NameValuePairList();
misc["externalWindowHandle"] = handle.ToString(); //handle of the main window
TopWindow = mRoot.CreateRenderWindow("TopWindow", 128, 128, false, misc);


The finalizationcode:

if (TopWindow != null)
{
mRoot.DetachRenderTarget(TopWindow);
TopWindow.RemoveAllViewports();
TopWindow.RemoveAllListeners();
TopWindow.Dispose();
TopWindow.Destroy();
TopWindow = null;
}

if (FontManager.Singleton != null)
FontManager.Singleton.UnloadAll();
if (MaterialManager.Singleton != null)
MaterialManager.Singleton.UnloadAll();
if (TextureManager.Singleton != null)
TextureManager.Singleton.UnloadAll();
if (FontManager.Singleton != null)
FontManager.Singleton.Dispose();
if (MaterialManager.Singleton != null)
MaterialManager.Singleton.Dispose();
if (TextureManager.Singleton != null)
TextureManager.Singleton.Dispose();

ResourceGroupManager.Singleton.ShutdownAll();
ResourceGroupManager.Singleton.Dispose();

Root.Singleton.Shutdown();
Root.Singleton.Dispose();
mRoot = null;


The finalization runs without any problems. The error comes at the very end of the application: AccessViolationExcption was undandled. When I click on "View Detail..." in the error window, a new small window opens telling that "Error creating window handle." I don't know how to debug this... please any suggestions?