当在服务器中执行以下代码时,它无法正常工作 [英] when execute the below code in server it is not working

查看:54
本文介绍了当在服务器中执行以下代码时,它无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下

Bitmap bitmap = new Bitmap(990, 540);
Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
graphics.CopyFromScreen(5, 160, 0, 0, bitmap.Size);
bitmap.Save(@"c:\\" + ddlSession.Text.ToString().Trim() + "DailySchedule.bmp", ImageFormat.Bmp);
lblUpdate.Text = "This image is saved";



当我在本地机器上执行上面的代码时,它正在工作,但当我在服务器错误中执行上述代码时,如下所示

System.ComponentModel .Win32Exception:句柄无效 .Error在下面的行显示如下


When i execute the above code in local machine it is working, but when i execute the above code in server error as follows
System.ComponentModel.Win32Exception: The handle is invalid.Error shows in below line as follows

graphics.CopyFromScreen(5, 160, 0, 0, bitmap.Size);

请帮帮我。我的代码有什么问题。



问候

Narasiman P.

Please help me. What is the problem in my code.

Regards
Narasiman P.

推荐答案

您可能遇到此处解释的问题:

http://social.msdn.microsoft.com/Forums/en-US/74e789ea-160b-4b89-8296-3274d1bff1de/copyfromscreen-giving-error-在服务器内 [ ^ ]
You may be experiencing the problem which is explained here:
http://social.msdn.microsoft.com/Forums/en-US/74e789ea-160b-4b89-8296-3274d1bff1de/copyfromscreen-giving-error-in-server[^]


这篇关于当在服务器中执行以下代码时,它无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆