Page 1 of 2

AccessViolation Exception

Posted: Mon Sep 12, 2005 5:11 pm
by blewisjr
Ok I fixed my code from the previous post and it now compiles but when I run the app I get a AccessViolation Exception stating that Irrlicht.NET.dll is trying to write to protected memory. Am I doing something wrong in my project settings or something. I am using C++/CLI and C++ Express beta 2.

Posted: Tue Sep 13, 2005 1:53 am
by blewisjr
I guess no one answers serious questions in this forum. Great suppor Irricht *claps*

Posted: Tue Sep 13, 2005 2:01 am
by Dances
What do you expect with one person programming and not many .NET developers?

Posted: Tue Sep 13, 2005 2:38 am
by Foole
Basd on the very little information you've provided, I would guess that you are doing something wrong. Happy now?

Posted: Tue Sep 13, 2005 10:35 am
by blewisjr
How much more information can I give. I converted the .Net example Hello World to C++/CLI. It compiles and when the mesh attempts to load it craps out saying it is trying to write to protected memory. That is all the information the compiler gave me. If you really want to know, the entire project has default settings except that I added a reference to the Irrlicht.NET.dll file.

Posted: Tue Sep 13, 2005 12:47 pm
by Mr. XYZ
Is the Irrlicht.dll in the same folder???

Posted: Tue Sep 13, 2005 8:03 pm
by blewisjr
Yes it is. Both dll's are in the folder. Like I said the code compiles but .Net is complaining it is trying to write to protected memory.

Posted: Tue Oct 04, 2005 3:07 am
by Silicon
I posted a similar thread with more info on my interactions resulting in the AccessViolation -- it only occurs when Irrlicht is run with OpenGL. I am running under .NET 2.0 (C# Express, with the July CTP of the framework). Are these also the case with your project?

Posted: Fri Oct 07, 2005 6:50 pm
by pfo
If Irrlicht.dll is trying to write protected memory, then my best guess would be you're doing something wrong with one of your pointers. This isn't a lot of help, can you break into the debugger and determine what line of code is causing this? Also, as Dances stated, there are not many .NET developers, I only come into this forum when I'm bored :) I would love to use .NET, but I know from reading in several places that some interfaces aren't supported yet or are missing functionality, so I just make do with C++ for now. Hopefully the next version will 100% .NET compatible (in a perfect world) and then I may wander over.

Posted: Thu Dec 08, 2005 8:14 pm
by Guest
Using VS2005 and C# Express 2005 with irrlicht.net-0.14.0

When trying to dispose the device I get:
System.AccessViolationException was unhandled
Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Source="Irrlicht.NET"
StackTrace:
at irr.IUnknown.drop(IUnknown* )
at Irrlicht.GUI.IGUIElement.Finalize()
The simplest code to reproduce the error:

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;
using Irrlicht;
using Irrlicht.Video;
using Irrlicht.Core;
namespace TestCase
{
    class Test
    {
        [STAThread]
        public static void Main(string[] args) {
            IrrlichtDevice device = new IrrlichtDevice(
                DriverType.OPENGL, 
                new Dimension2D(1024, 768), 
                32, 
                false, 
                true, 
                true);
            device.CloseDevice();
        }
    }
}
All drivers apart from OpenGL seem to dispose correctly. This error means that applications using OpenGL will offer to send a bug report to Microsoft every time they are run (outside Visual Studio), which is clearly not an ideal situation.

Posted: Thu Dec 08, 2005 8:17 pm
by kable
Session timed out :(

If you want any clarification to my test case post, contact me

Posted: Thu Dec 08, 2005 8:26 pm
by pfo
Can you try catching that exception and ignoring it? Not an ideal solution, but then neither is sending a bug report all the time. I wonder why guest's code crashes (is that you kable?). I'll try reproducing the problem in C++ to see what happens (I think it should work though).

Posted: Mon Dec 12, 2005 11:47 am
by kable
Unfortunately, the exception is not able to be caught, I think because it is being raised after the end of the c# code by something in irrlicht destructors. I'm starting to think that it may be from the log window because when I use the following dirty hack:

Code: Select all

            while (device != null)
            {
                device.CloseDevice();
                Thread.Sleep(100); 
            }

... the logger window stays open, and no exception occurs. When the logger window is closed the application exits neatly. Then I realised that closing the logger window causes a neat exit without raising the exception... could the problem be caused by this window not being closed when close device is called?

Posted: Mon Dec 12, 2005 9:10 pm
by pfo
It works fine in C++, it must be some obscure bug. Very strange. I've had the console logger window open before in the background of an app before with no problems, maybe this is a problem with .NET?

Posted: Thu Dec 29, 2005 12:36 pm
by NewYoda
I get the same AccessViolation while exiting (OPENGL) or while calling SceneManager.DrawAll (SOFTWARE2). If I use DirectX 8/9 or Software, I don't get the exception .........