2010-12-03 203 views
2

我使用下面的代碼來打印我的網頁。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) 

它非常迫切。 任何建議,請...... .....

回答

1

我猜想圖形功能只適用於富客戶端應用程序。 (Windows Forms)

如果網頁可以捕獲用戶桌面的快照,這將是一個巨大的安全問題。

+0

謝謝萊昂。 我想知道是否有任何工具可用來完成這項任務。我正在爲其他幾個人工作。任何建議都會有很大的幫助...... – Vani 2010-12-10 22:04:08

0

您可以試試VisualJS.NET,在頁面下的視頻可能會有幫助。除了內置的VisualJS.NET功能之外,他們還使用Cassini Dev服務器,以便通過Web應用程序演示非常簡單的遠程桌面。