09-01-2018, 05:55 PM
I somewhat reproduced the issue:
Commented out line 76 in Platformer.cs (// engine.SetRasterCallback(callback);):
It doesn't crash at all, the frame is partially drawn because it lacks the raster effects but it runs as expected.
Restored line 76 and inserted a return in line 130, just at the beggining of the MyRasterEffects() function:
It crashes again. So it's definitely something with the delegate manager in C#
Copied the generated .exe file from /bin/Debug to the root folder and executed it outside the debugger, double clicking it:
It crashes.
Changed project properties: Set to C# 5.0 and .NET 4.0:
It crashes when running from the debugger, but if I copy the resulting .exe from bin/Debug to the root folder and execute it directly, it DOES NOT crash.
So it seems to be a combination of the environment, the .NET target and the debugger...
- Using SharpDevelop 5.1 (I had this already installed).
- Created a simple console application targeting .NET 2.0 and C# 2.0
- Added "Tilengine.cs" and "Platformer.cs"
- Copied 32-bit versions of "Tilengine.dll" and "SDL2.dll" to the project root folder
- Build without problems
- Run from the debugger, hitting F5
Code:
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 d:\Tilengine\samples\csharp2\Tilengine.cs:line 808
at Platformer.Main(String[] args) in d:\Tilengine\samples\csharp2\Platformer.cs:line 116
Commented out line 76 in Platformer.cs (// engine.SetRasterCallback(callback);):
It doesn't crash at all, the frame is partially drawn because it lacks the raster effects but it runs as expected.
Restored line 76 and inserted a return in line 130, just at the beggining of the MyRasterEffects() function:
It crashes again. So it's definitely something with the delegate manager in C#
Copied the generated .exe file from /bin/Debug to the root folder and executed it outside the debugger, double clicking it:
It crashes.
Changed project properties: Set to C# 5.0 and .NET 4.0:
It crashes when running from the debugger, but if I copy the resulting .exe from bin/Debug to the root folder and execute it directly, it DOES NOT crash.
So it seems to be a combination of the environment, the .NET target and the debugger...