0

我是新手。我在过去 2 天得到了这个异常并且没有得到解决:(它在 vs 2008 中运行良好但是当我执行 exe 文件时它会在一段时间后给出异常

例外是

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

代码是

         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);


    }

例外状态

4

0 回答 0