我正在尝试捕获屏幕,此代码正在本地服务器上运行,但是当我在Web服务器上运行System.ArgumentException时:出现参数无效异常。这是我的代码
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
using (Graphics memoryGraphics = Graphics.FromImage(bitmap))
{
memoryGraphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,Screen.PrimaryScreen.Bounds.Y,0,0,bitmap.Size,CopyPixelOperation.SourceCopy);
//// graphics.CopyFromScreen(143, 63, 100, 100, bitmap.Size);
}
以下是例外:
[ArgumentException:参数无效。] System.Drawing.Graphics.GetHdc()+ 1138213 System.Drawing.Graphics.CopyFromScreen(Int32 sourceX,Int32 sourceY,Int32 destinationX,Int32 destinationY,Size blockRegionSize,CopyPixelOperation copyPixelOperation)+413 _Default.Button9_Click1(Object sender,EventArgs e)位于d:\ home \ site \ wwwroot \ CS.aspx.cs:173 System.Web.UI.WebControls.Button.OnClick(EventArgs e)+9696694 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)+204 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+12 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+15 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+9654230 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+1639'