Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C# sample attempted to read or write protected memory.
Whenever I run the C# sample, it gives me the following error:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Tilengine.Window.TLN_DrawFrame(Int32 time)
at Tilengine.Window.DrawFrame(Int32 time) in c:\Users\Dallas\Downloads\Tilengine_windows_win32\samples\csharp\Tilengine.cs:line 808
at Platformer.Main(String[] args) in c:\Users\Dallas\Downloads\Tilengine_windows_win32\samples\csharp\Platformer.cs:line 116

I copy-pasted tilengine.dll, because it is required. Also, I am using SharpDevelop.
I got the C# sample to run... I wonder if you set up the project correctly? Or if something changed in the Tilengine downloads since I tried it...
I see that RexyDallas build is 32-bit windows. I can't test that setup because my Windows is 64-bit and the .NET runtime loads the dll that matches the OS version. To test it, one has to setup a 32-bit Windows.

Maybe the transition to the LGPL 2.0 relesase has touched some files that I haven't noticed... I'll check it
I've tested on windows 7 through to windows 10 both 32bit and 64bit its works fine for me, tried both 2.0 and 2.1.

If you could run the .net framework repair tool, I had major issues when i upgraded from windows 7 to windows 10

Edit: Just did a test using 32bit c# and used the 64bit tilengine dll and i got a message very much the same as above, so maybe its case of mixing up 32/64bit
This PC came with windows 10. Also, SharpDevelop doesn't support debugging 64-bit processes. Also, I simply copy-pasted the tilengine.dll that was included with the 32-bit version. Also, it only crashes when window.DrawFrame(frame); is called.

Also, when I comment out "engine.SetRasterCallback(callback);", it runs perfectly. However, when I comment out the contents of that function, it still crashes.
are you using mono or .net
I am using .net. The target framework is ".NET Framework 2.0". Also, I should note, the full frame is drawn.
Seems to be related to the C# "delegates" (the equivalent of C function pointers).

The correct startup and render the full frame denotes correct matching of .net/native dll. If not, it wouldn' start at all.
The fact that it crashes when the delegate callback is called denotes a delegate managing problem, something that can be tricky.

The error happens only running from the debugger in SharpDevelop? Can you run the executable directly from the command line or double-clicking it? We have to discard the environment itself doing funny things. My test environment is Visual Studio (it's free) and it runs there.
It even crashes when I run it without attached debugger. Also, I manually installed .net x64, even though windows comes with it. When I compile it with the SDK command prompt, it still gives me the error. Though, it gives me a warning about 'mscorlib.dll' targeting a different processor. However, I do not get that warning in SharpDevelop unless I change the target platform. Also, I can't figure out how to compile 64-bit.

Edit: I got the x64 version to run and work perfectly after copying sdl2.dll and tilengine.dll from SuperMarioClone. Though, doing the same for the 32-bit version leads to a white screen with the same crash.
Just a test I downloaded sharpdevelop and created a new project it compiled and ran perfectly, there is clearly a setting in the project file that is messing things up

Forum Jump:

Users browsing this thread: 1 Guest(s)