Graphics.CopyFromScreen [Web应用程序] +句柄无效 [英] Graphics.CopyFromScreen [Web application] + The handle is invalid

查看:1129
本文介绍了Graphics.CopyFromScreen [Web应用程序] +句柄无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用(Bitmap bitmap = new Bitmap(bitmap bitmap = new Bitmap (图形g = Graphics.FromImage(位图))
{
g.CopyFromScreen(new Point(bounds.Left,bounds.Top))
{
using ,Point.Empty,bounds.Size);
}
bitmap.Save(System.AppDomain.CurrentDomain.BaseDirectory.ToString()+ 1 +.JPEG,ImageFormat.Jpeg);
}

它在开发机器中工作正常,但是一旦我将其部署在Server
给出下面的错误



错误消息:

 该句柄无效
来源:System.DrawingError
堆栈跟踪:在System.Drawing.Graphics.CopyFromScreen(Int32 sourceX,Int32 sourceY,Int32 destinationX,Int32目标Y,大小blockRegionSize,CopyPixelOperation copyPixelOperation)
在System.Drawing.Graphics.CopyFromScreen(Int32 sourceX,Int32 sourceY,Int32 destinationX,Int32 destinationY,Size blockRegionSize)$ b $ System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource,Point upperLeftDestination,Size blockRegionSize)
在Secure_SearchReport.btnSearch_Click(Object sender,EventArgs e)
在System.Web.UI.WebControls.Button.OnClick(EventArgs e)
在System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
在System.Web.UI。 WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)

非常紧急。
任何建议请...... .....

解决方案

我猜想图形功能只有在丰富客户端应用程序。 (Windows Forms)



如果网页可以捕捉用户桌面的快照,这将是一个巨大的安全问题。


I am using the below code to take print screen of my web page.

      using (Bitmap bitmap = new Bitmap(620, 850))
        {    
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size);
            }
            bitmap.Save(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + 1 + ".JPEG", ImageFormat.Jpeg);
        }

It works fine in the development machine,but once i deploy it in the Server it gives below error

Error Message:

The handle is invalid
Source: System.DrawingError
Stack Trace:    at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)    
   at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)    
   at System.Drawing.Graphics.CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)    
   at Secure_SearchReport.btnSearch_Click(Object sender, EventArgs e)    
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)    
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)    
   at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)    
   at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

Its very urgent. Any suggestion please.......

解决方案

I would guess the graphics functionality is only available in rich-client applications. (Windows Forms)

This would be a huge security issue if webpages could capture snapshots of users' desktop.

这篇关于Graphics.CopyFromScreen [Web应用程序] +句柄无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆