I am trying to create a game in WinForms but after running a while it throws an Access-violation-Exception
I tried changing some settings as found in answers to similar questions but none worked.
If it helps: I use no P/Invoke other than this:
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern short GetKeyState(int keyCode);
public static bool IsKeyDown(Keys key)
{
try
{
int state = 0;
short retVal = GetKeyState((int)key);
if ((retVal & 0x8000) == 0x8000)
state |= 1;
if ((retVal & 1) == 1)
state |= 2;
return 1 == (state & 1);
}
catch (Exception e1)
{
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e1.ToString());
return false;
}
}
It simply exits with Exception thrown at 0x76C391EA (msvcrt.dll) in LaptopSimulator2015.exe: 0xC0000005: Access violation reading location 0x0D39864A. occurred
after about a minute.
Is this my fault?
What can I do to find out where the Exception is thrown?
EDIT: It somehow fixed itself after moving the solution folder somewhere else. Seems to have been caused by Visual Studio.
User contributions licensed under CC BY-SA 3.0