我使用以下代码来获取我的网页的打印屏幕。
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);
}
它在开发机器上工作正常,但是一旦我在服务器中部署它 它给出了以下错误
错误讯息:
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)
非常迫切。 任何建议请.......
答案 0 :(得分:1)
我猜想图形功能仅在富客户端应用程序中可用。 (Windows窗体)
如果网页可以捕获用户桌面的快照,那么这将是一个巨大的安全问题。
答案 1 :(得分:0)
您可以尝试VisualJS.NET,http://www.visualjs.net/Tutorials/WhatisVisualJSNET.aspx页面下的视频可能会有所帮助。他们使用Cassini Dev服务器以及内置的VisualJS.NET功能,以演示非常简单的远程桌面而不是Web应用程序。