2009-12-15 83 views
9

是否存在一個錯誤報告框架,建議您在.net中使用。我需要像電子郵件報告和文件發送到電子郵件的可能性。用戶應該有可能向報告添加信息,並且應該有可能刪除報告文件,即它們是否包含隱私關鍵數據。也應該有可能採取自動截圖。 所需的框架還應包括錯誤報告guis。它應該讓我有可能爲錯誤報告創建自己的guis。.net的錯誤報告框架

我已經使用log4net,但據我所知,這是不可能的,以顯示gui錯誤報告給用戶。

,如果有任何意見就好了,

問候,馬丁

+1

參見http://stackoverflow.com/questions/49224/good-crash-reporting-library-in-c – 2010-08-02 01:17:58

+0

Visual Studio應用程序見解是你需要的東西! https://azure.microsoft.com/en-us/documentation/articles/app-insights-windows-desktop/ – smedasn 2016-04-24 15:51:04

回答

5

你試過Elmah?它執行所有你正在談論的錯誤處理元素。你可以看看Trac來找到你想要的bug。

善良,

4

我熟悉的「微軟企業庫日誌程序塊」和「log4net的」,並且這兩種適合您的要求(有多個日誌監聽器) 這裏是一個頁面,這兩個比較:http://weblogs.asp.net/lorenh/archive/2005/02/18/376191.aspx

+0

我已經使用log4net,但有log4net創建崩潰報告窗口的可能性?由於隱私原因,無法使用日誌文件生成自動郵件。用戶必須有可能決定是否報告崩潰。 – martin 2009-12-17 08:51:01

1

有是Microsoft WER,但是您需要在Winqual註冊並且您的公司需要有VeriSign ID。對很多人來說太麻煩了。

0

微軟的Enterprise Library,最新版本4.1-October 2008被廣泛用於異常處理和日誌記錄等。還有一個很好的GUI構建器,可以修改你的app.config或web.config文件。

3

退房由The Object Guy

+0

它被命名爲「白蟻」,並轉移到http://dotnetlog.theobjectguy.com/ – Lucas 2010-02-11 18:12:20

0

做出的日誌框架您也可以嘗試log4net。不過,我不確定電子郵件。但是,它是可擴展的。另外你可以得到源代碼!

+2

他說他已經使用log4net。 – 2012-03-07 19:59:27

3

Red Gate有一個名爲SmartAssembly的產品可以進行錯誤報告。我自己並沒有使用它,但公司有良好的聲譽。

+0

請注意,您不能在Visual Studio在線構建管道中使用它,因爲它需要使用許可證密鑰進行安裝。如果可以的話 - 給我發消息解決方案:) – 2017-02-09 11:07:30

4

滾動您自己的異常處理程序。在你的program.cs類中使用下面的代碼。發生異常時它會自動發送郵件。

using System; 
using System.Windows.Forms; 
using System.Net; 
using System.Net.Mail; 
using System.Threading; 

namespace ExceptionHandlerTest 
{ 
    static class Program 
    { 
     /// <summary> 
     /// The main entry point for the application. 
     /// </summary> 
     [STAThread] 
     static void Main() 
     { 
      Application.ThreadException += 
       new ThreadExceptionEventHandler(Application_ThreadException); 

      // Your designer generated commands. 
     } 

     static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) 
     { 

      var fromAddress = new MailAddress("your Gmail address", "Your name"); 
      var toAddress = new MailAddress("email address where you want to receive reports", "Your name"); 
      const string fromPassword = "your password"; 
      const string subject = "exception report"; 
      Exception exception = e.Exception; 
      string body = exception.Message + "\n" + exception.Data + "\n" + exception.StackTrace + "\n" + exception.Source; 

      var smtp = new SmtpClient 
      { 
       Host = "smtp.gmail.com", 
       Port = 587, 
       EnableSsl = true, 
       DeliveryMethod = SmtpDeliveryMethod.Network, 
       UseDefaultCredentials = false, 
       Credentials = new NetworkCredential(fromAddress.Address, fromPassword) 
      }; 
      using (var message = new MailMessage(fromAddress, toAddress) 
      { 
       Subject = subject, 
       Body = body 
      }) 
      { 
       //You can also use SendAsync method instead of Send so your application begin invoking instead of waiting for send mail to complete. SendAsync(MailMessage, Object) :- Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes. 
       smtp.Send(message); 
      } 
     } 
    } 
} 
+0

這太好了,謝謝!我希望我能接受你的答案是正確的。我在我的項目中使用了它,並且完美地工作。我發現如果你發現異常,那麼它不會調用郵件報告。但是我已經從中做出了一個類,並且我在「嘗試,捕捉」中調用它,所以用戶仍然可以看到錯誤報告。 – MiKE 2014-09-17 00:09:46

+0

我喜歡簡單,但我不喜歡程序中的硬編碼密碼,可能會被濫用,應該是一種包裝它的方式,因此無法從MSIL程序集中輕鬆查看。 – rolls 2016-10-19 21:44:14

+1

@rolls我創建了這個不需要SMTP電子郵件的代碼庫。它使用Drdump服務收集崩潰。你可以在https://crashreporterdotnet.codeplex.com/找到它。 – 2016-12-04 06:37:37