I am trying to capture the Screen. that is when our website was running that time particular webpage capture and store it folder. this work fine but when we publish the web it gives exception
Source Code System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap as System.Drawing.Image);
graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
bitmap.Save(@"c:\myscreenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Exception Server Error in '/OnlineAutomation' Application.
The handle is invalid
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ComponentModel.Win32Exception: The handle is invalid
Source Error:
Line 54: System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap as System.Drawing.Image);
Line 55:
Line 56: graphics.CopyFromScreen(25, 25, 25, 25, bitmap.Size);
Line 57:
Line 58: bitmap.Save(@"c:\myscreenshot.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Source File: c:\Inetpub\wwwroot\OnlineAutomation\Forms\test.aspx.cs Line: 56
Stack Trace:
[Win32Exception (0x80004005): The handle is invalid]
System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) +542
System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize) +29
Forms_test.btnsave_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\OnlineAutomation\Forms\test.aspx.cs:56
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053