i am newbie. i am getting this exception last 2 days and not get solved :( it runs fine in vs 2008 but when i execute exe file it gives Exception after some time
the exception is
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at clienttesting.EventLoop.GetMessage(MSG& lpMsg, IntPtr hWnd, UInt32 wMsgFil terMin, UInt32 wMsgFilterMax) at clienttesting.EventLoop.Run() in D:\noman\windowsconsole\windowsconsole\Pr ogram.cs:line 196 at clienttesting.Program.Main() in D:\noman\windowsconsole\windowsconsole\Pro gram.cs:line 35
the code is
public static void Run()
{
MSG msg = new MSG();
sbyte ret;
do
{
if ((ret = GetMessage(out msg, IntPtr.Zero, 0, 0)) != -1)
{
Thread.Sleep(1000);
Console.WriteLine("the mesaaeg" + msg.Message.ToString());
if (msg.Message == WM_QUIT)
{
break;
}
if (ret == -1)
{
break; //-1 indicates an error
}
else
{
TranslateMessage(ref msg);
DispatchMessage(ref msg);
}
}
} while (true);
}
the Exception states