我使用下面的代碼來打印我的網頁。Graphics.CopyFromScreen [Web應用程序] +句柄無效
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)
它非常迫切。 任何建議,請...... .....
謝謝萊昂。 我想知道是否有任何工具可用來完成這項任務。我正在爲其他幾個人工作。任何建議都會有很大的幫助...... – Vani 2010-12-10 22:04:08