.net 的错误报告框架

Error-reporting framework for .net

提问人:martin 提问时间:12/15/2009 最后编辑:Ognyan Dimitrovmartin 更新时间:2/9/2017 访问量:9250

问:

您是否建议在 .NET 中使用错误报告框架。我需要诸如电子邮件报告之类的可能性,并将文件附加到电子邮件中。用户应该有可能向报告添加信息,也应该有可能删除报告文件,即如果它们包含隐私关键数据。还应该有可能进行自动截屏。 所需的框架还应包括错误报告 gui。它应该使我有可能创建自己的 gui 来报告错误。

我已经使用了log4net,但据我所知,不可能向用户显示用于报告错误的GUI。

如果有任何建议就好了,

问候,马丁

C# .NET 处理 错误 报告 bug 跟踪

评论

1赞 dan-gph 8/2/2010
另请参阅 stackoverflow.com/questions/49224/...
0赞 smedasn 4/24/2016
Visual Studio Application Insights 就是你所需要的!azure.microsoft.com/en-us/documentation/articles/......

答:

5赞 Daniel Elliott 12/15/2009 #1

你试过艾尔玛吗?它执行您所说的所有错误处理元素。您可能会在 Trac 上寻找您想要的 bug 处理位。

1赞 jmservera 12/15/2009 #2

检查企业库,您有一个完全可配置和可扩展的日志记录和异常处理应用程序日志。

4赞 A9S6 12/15/2009 #3

我熟悉“Microsoft 企业库日志记录块”和“Log4Net”,这两者都符合您的要求(具有多个日志侦听器) 以下是比较这两者的页面: http://weblogs.asp.net/lorenh/archive/2005/02/18/376191.aspx

评论

0赞 martin 12/17/2009
我已经使用 log4net,但是 log4net 是否有可能创建崩溃报告窗口?由于隐私原因,无法生成带有日志文件的自动邮件。用户必须能够决定是否报告崩溃。
1赞 Konamiman 12/15/2009 #4

Microsoft WER,但是您需要在Winqual注册,并且您的公司需要有一个VeriSign ID。 对许多人来说太麻烦了。

0赞 John K 12/15/2009 #5

Microsoft 的企业库,最新版本 4.1-2008 年 10 月广泛用于异常处理和日志记录等。还有一个不错的 GUI 构建器,可以修改您的 app.config 或 web.config 文件。

3赞 Klaus Byskov Pedersen 12/15/2009 #6

查看 The Object Guy 制作的日志框架

0赞 Kerido 2/9/2010 #7

您也可以尝试log4net。不过,我不确定电子邮件。但是,它是可扩展的。另外,您可以获取源代码!

3赞 dan-gph 8/2/2010 #8

Red Gate 有一款名为 SmartAssembly 的产品,可以进行错误报告。我自己没有用过,但公司口碑很好。

评论

0赞 Ognyan Dimitrov 2/9/2017
请注意,不能在 Visual Studio Online 生成管道中使用它,因为它需要使用许可证密钥进行安装。如果可以的话 - 将解决方案发送给我:)
4赞 Ravi Patel 5/15/2012 #9

滚动自己的异常处理程序。在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 9/17/2014
这太好了,谢谢!我希望我能接受你的回答是正确的。我在我的项目中使用了它,并且效果很好。我发现如果您捕获异常,那么它不会调用邮件报告。但是我已经从中创建了一个类,并在“try,catch”中调用它,因此用户仍然会直观地收到错误报告。
0赞 rollsch 10/20/2016
我喜欢它的简单性,但我不喜欢程序中的硬编码密码,容易被滥用,应该是一种包装它的方法,这样它就不能从 MSIL 程序集中轻松查看。
1赞 Ravi Patel 12/4/2016
@rolls我用这段代码创建了库,现在不需要 SMTP 的电子邮件。它使用 Drdump 服务来收集崩溃。您可以在以下位置找到它 crashreporterdotnet.codeplex.com