【问题标题】:Win32Exeption: The operation completed successfully... graphicsWin32Exeption:操作成功完成...图形
【发布时间】:2012-05-16 18:52:39
【问题描述】:

我搜索了一些解决方案,但没有一个人给出解决方案......如果有人能解释它为什么会发生以及如何解决它(以简单的方式),我将不胜感激:)

总是在同一个地方发生……在我启动程序几分钟后。

private static Bitmap bmpScreenShot;
private static Graphics gfxScreenShot;
...
...

bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
    Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
gfxScreenShot = Graphics.FromImage(bmpScreenShot);
gfxScreenShot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
    Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, 
    CopyPixelOperation.SourceCopy); // <-- Occurs here a while after ive started the application

在发生这种情况之前它会运行几次(比如 40-80 次):

Win32Exeption 未处理:操作成功完成

【问题讨论】:

    标签: c# .net graphics exception-handling win32exception


    【解决方案1】:

    在继续之前,先创建一个 try and catch 语句:

    try
    {
        //Your code goes here
    }
    catch (Win32Exception e)
    {
        //Handle the exception here, or use one of the following to find out what the issue is:
        Console.WriteLine(e.Message);
        MessageBox.Show(e.Message, "Exception");
    }
    

    【讨论】:

    • 它又跑了一次,只到 bmpScreenShot = 行说(ArgumentExeption 未处理 |-| 参数无效。)...对此有任何解决方案吗?...顺便说一句(是吗?不管我是否在黄色三角形上出现错误,或者我可以跳过它们吗?)
    • 当我为此添加一个例外时,每次调用此代码时都会发生这种情况,导致代码 bmpScreenShot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb );不被执行:S
    【解决方案2】:

    原来我必须这样做 bmpScreenShot.Dispose();gfxScreenShot.Dispose();

    【讨论】:

      猜你喜欢
      • 2012-01-17
      • 1970-01-01
      • 2011-10-01
      • 1970-01-01
      • 2010-11-26
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多