2009-12-15 90 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