0
我有以下例外擴展爲我的內部Winform應用程序。我的問題是,我得到一個generic GDI+
錯誤ss.save("C:\\HelpMe.jpg", ImageFormat.Jpeg);
GDI +在ScreenShot上的一般錯誤
這不是每一次,因爲它會工作,然後出錯。有時它會連續工作幾次。
這可能是「鎖定」問題嗎?我還應該看什麼和/或做錯了什麼。
我把這個像這樣 - >
catch (Exception ex)
{
ex.LogError(HUD.ShellForm);
}
public static void LogError(this Exception exception, DevExpress.XtraEditors.XtraForm whichForm)
{
GetDesktopImage(whichForm);
SendExceptionMail(exception);
ExceptionMessageBox box = new ExceptionMessageBox(exception);
box.Show(whichForm);
}
private static void SendExceptionMail(Exception exception)
{
SmtpClient smtpClient = new SmtpClient("MailServer");
MailMessage message = new MailMessage
{
From = new MailAddress("[email protected]"),
Subject = "MATRIX Application Error",
Body = exception.Message
};
Attachment attachment = new Attachment(@"C:\\HelpMe.jpg");
message.Attachments.Add(attachment);
message.To.Add("[email protected]");
message.To.Add("[email protected]");
smtpClient.Send(message);
}
///<summary>
/// Grabs a screen shot of the App and saves it to the C drive in jpg
///</summary>
private static void GetDesktopImage(DevExpress.XtraEditors.XtraForm whichForm)
{
Rectangle bounds = whichForm.Bounds;
using (Bitmap ss = new Bitmap(bounds.Width, bounds.Height))
using (Graphics g = Graphics.FromImage(ss))
{
g.CopyFromScreen(whichForm.Location, Point.Empty, bounds.Size);
ss.Save("C:\\HelpMe.jpg", ImageFormat.Jpeg);
}
}
這是贏7,我們所有的用戶都是本地管理員(不要射擊信使)。另外,如果這是問題,我不認爲我能夠首先創建文件.... – 2009-09-10 01:42:35