0

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

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

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 未处理:操作成功完成

4

2 回答 2

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");
}
于 2012-05-16T19:03:00.070 回答
0

原来我不得不bmpScreenShot.Dispose();gfxScreenShot.Dispose();

于 2012-05-20T18:26:31.740 回答