![]() |
C# sample attempted to read or write protected memory. - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7) +--- Thread: C# sample attempted to read or write protected memory. (/showthread.php?tid=172) Pages:
1
2
|
C# sample attempted to read or write protected memory. - RexyDallas - 08-25-2018 Whenever I run the C# sample, it gives me the following error: Code: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. I copy-pasted tilengine.dll, because it is required. Also, I am using SharpDevelop. RE: C# sample attempted to read or write protected memory. - Domarius - 08-25-2018 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... RE: C# sample attempted to read or write protected memory. - megamarc - 08-25-2018 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 RE: C# sample attempted to read or write protected memory. - greysonstorm - 08-28-2018 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 https://www.microsoft.com/en-us/download/details.aspx?id=30135 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 RE: C# sample attempted to read or write protected memory. - RexyDallas - 08-30-2018 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. RE: C# sample attempted to read or write protected memory. - greysonstorm - 08-30-2018 are you using mono or .net RE: C# sample attempted to read or write protected memory. - RexyDallas - 08-30-2018 I am using .net. The target framework is ".NET Framework 2.0". Also, I should note, the full frame is drawn. RE: C# sample attempted to read or write protected memory. - megamarc - 08-31-2018 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. RE: C# sample attempted to read or write protected memory. - RexyDallas - 08-31-2018 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. RE: C# sample attempted to read or write protected memory. - greysonstorm - 08-31-2018 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 |