Graphics.CopyFromScreen 未处理Win32Exception 操作成功完成

lxd824 2012-03-08 02:36:17
程序中只要用到CopyFromScreen就报错
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.CopyFromScreen(this.Location,
new Point(4, 4), new Size(10, 10));
}

详细错误信息:
未处理 System.ComponentModel.Win32Exception
Message="操作成功完成。"
Source="System.Drawing"
ErrorCode=-2147467259
NativeErrorCode=0
StackTrace:
在 System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
在 System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)
在 System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
在 TestCapture.Form1.Form1_Paint(Object sender, PaintEventArgs e) 位置 D:\测试用例\ZCCapture\TestCapture\Form1.cs:行号 48
在 System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
在 System.Windows.Forms.Form.OnPaint(PaintEventArgs e)
在 System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
在 System.Windows.Forms.Control.WmPaint(Message& m)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 TestCapture.Program.Main() 位置 D:\测试用例\ZCCapture\TestCapture\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException:
...全文
381 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxd824 2012-03-08
  • 打赏
  • 举报
回复
把.net framework2.0及其相关的东西卸载掉就好了。
注:我电脑上装了所有版本的.net framework 不晓得是不是产生了冲突,猜测!
lxd824 2012-03-08
  • 打赏
  • 举报
回复
以上说的都不行,这程序我换了几台机器测试了下,有的行有的不行,不知道什么原因。 可不可能是.net framework 装的不行?
  • 打赏
  • 举报
回复
e.Graphics.CopyFromScreen(this.Location,
new Point(4, 4), new Size(10, 10));

是不是位置有点不对啊
kong19 2012-03-08
  • 打赏
  • 举报
回复
同样的代码我这里没有错误。。。

你把工程rebuild一下,重新试试

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧