Win32Exeption: 操作已成功完成..图形
本文关键字:图形 成功 操作 Win32Exeption | 更新日期: 2023-09-27 18:34:28
>我搜索了一些解决方案,但没有一个人显示解决方案......如果有人能解释为什么会发生以及如何(以简单的方式(解决它,我将不胜感激:)
一直发生在同一个地方...启动程序几分钟后。
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 次(:
Win32 未处理:操作已成功完成
在继续之前,请创建一个 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.Dispose();
和gfxScreenShot.Dispose();