2009-09-09 5 views
0

다음과 같은 내선 Winform 응용 프로그램에 대한 Exception Extension이 있습니다. 내 문제는 ss.save("C:\\HelpMe.jpg", ImageFormat.Jpeg);generic GDI+ 오류가 발생했습니다.ScreenShot에서 GDI + 일반 오류가 발생했습니다.

언제든지 작동하고 오류가 발생할 때마다 나타나는 것은 아닙니다. 때로는 두 번 연속으로 작동합니다.

"잠금"문제 일 수 있습니까? 그 밖의 무엇을보고해야하며 잘못하고 있습니까?

그래서 같은이 전화 ->


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); 
     } 
    } 

답변

1

때문에 보통이다 :

  1. 대상 디렉토리
  2. 존재하지 않습니다 대상 파일 이름이 이미 사용 중입니다
  3. 대상 파일 이름은

    기본적으로이 일반적으로 발생합니다 ... 실제로 사용자가 등을 대상 파일

...에 대한 쓰기 액세스 권한이없는

  • 디렉토리입니다 GDI가 파일을 만들거나 쓸 수 없기 때문입니다. BTW, 비스타에서 당신은 C : \

  • +0

    에 대한 쓰기 권한이 없습니다. Win 7이며 모든 사용자는 로컬 관리자입니다 (메신저를 쏘지 마십시오). 또한, 그것이 문제라면 처음부터 파일을 만들 수있을 것이라고 생각하지 않습니다 .... –

    관련 문제