简单的崩溃报告?

发布于 2024-10-07 15:39:41 字数 578 浏览 0 评论 0原文

我正在考虑在我的应用程序上实现一个简单的崩溃报告,该报告将询问用户是否愿意将崩溃日志发送给我们。

我以前从未做过崩溃报告,我习惯做的是将错误保存到日志文件中的尝试/捕获。

  1. 实现崩溃报告系统的正确方法是什么?

  2. 当应用程序崩溃时,如何触发崩溃报告打开并发送转储,或者发送数据的正确方法是什么?

我认为以上是我对其如何工作或应该工作的最大疑问......我不完全确定崩溃报告是否当上述情况发生时,将触发 try/catchs 与外部应用程序的交互,或者遵循它的正确方法是什么。

我没有可用的 SQL Server,因此我计划使用一个简单的上传脚本,报告转储的应用程序将使用该脚本来发送数据。

请原谅我对崩溃报告的工作原理一无所知,我希望社区能够帮助我更好地理解它。

我正在搜索有关崩溃报告的内容,并看到大多数内容都围绕着 Crystal Report,准备好去图书馆等等,但我想从小处开始,这样我就可以在深入研究一些大型库或其他解决方案(如果我可以使用)之前更好地理解它。

I am looking into implementing a simple crash report on my application that will ask the user if he wants or not to send the crash log to us.

I never did a crash report before, what I am used to do is a try/catch around saving the errors to a log file.

  1. What is the correct way to implement a crash report system ?

  2. How do you trigger the crash report to open and send the dump when the application crashs or what is the correct approch to send the data ?

I think the above are my biggest doubts as to how it works or should work... I am not entirely sure if the crash report would be a interact of try/catchs with a external app trigged when the above happens or what would be the correct way to follow it.

I dont have SQL Server available so what I was planning to use would be a simple upload script that the app to report the dump would use to send the data.

Pardon me for my ignorance about how the crash report works and I hope the community can help me understand it better.

I was searching around about crash report and saw most things going around Crystal Report, ready to go libraries, etc but I would like to start it small so I can get a better understanding of it before digging into some big library or other solution if it is available at my end.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苍暮颜 2024-10-14 15:39:41

您是否考虑过使用内置的Windows 错误报告

您可以使用 Winqual 网站
查看特定于驱动程序的,
特定于应用程序或操作
与相关的系统特定错误
您的组织。每个错误报告
提供与此相关的详细信息
桶,然后您可以请求
相关数据的文件。

查看错误报告:

  1. 建立 Winqual 帐户。保护公司免遭冒充
    并确保错误报告
    去找一位代表
    正确的公司,Winqual 网站
    要求贵公司拥有有效的
    威瑞信 ID。

• 请咨询您的法律部门;
您的公司可能已经有
VeriSign ID(也称为软件
出版商的数字 ID
验证码)。 • 检查Winqual
看看您的公司是否已经有
帐户。

  1. 接受 Windows 错误报告协议。

  2. 登录 Winqual 网站。

  3. 点击“Windows 错误报告”。

这篇旧文章可能会感兴趣:A Simple Class to Catch Unhandled Exceptions in WinForms

Have you considered using the built-in Windows Error Reporting?

You can use the Winqual website to
view driver-specific,
application-specific, or operating
system-specific errors associated with
your organization. Each error report
provides details related to that
bucket, and you can then request a
file of the associated data.

To view error reports:

  1. Establish a Winqual account. To protect companies from impersonation
    and to ensure that the error reports
    go to a representative from the
    correct company, the Winqual Web site
    requires your company to have a valid
    VeriSign ID.

• Check with your Legal Department;
your company might already have a
VeriSign ID (also called a Software
Publisher's Digital ID for
Authenticode). • Check on Winqual
to see if your company already has an
account.

  1. Accept the Windows Error Reporting Agreement.

  2. Sign in to the Winqual site.

  3. Click Windows Error Reports.

This old article may be of interest: A Simple Class to Catch Unhandled Exceptions in WinForms

撩心不撩汉 2024-10-14 15:39:41

很大程度上取决于应用程序以及(特别是)用户预期的隐私问题。

假设这是一个在用户 PC 上运行的客户端应用程序,如果这是一个“Intranet”内部应用程序,那么让应用程序在退出时通过电子邮件将日志文件发送给您应该非常简单。

这可能非常有趣,因为有时您会在用户报告错误之前修复该错误。

或者,如果您担心应用程序可能崩溃并且无法正确捕获未处理的异常,您可以

  1. 在启动时编写一个注册表项(或虚拟文件项,或其他什么)来标记“应用程序未正确终止”
  2. 在干净退出时,清理注册表项(或您拥有的内容)
  3. 在启动时,检查注册表项(等)是否存在。

如果标记存在,那么您就知道应用程序以不干净的方式崩溃,因此您可以用文本提示用户,例如“上次运行此程序时,它似乎没有正确退出。您想发送一个吗?”记录发生在我们身上的事情,以便我们可以尝试解决可能发生的任何问题?”

Much depends on the application and (in particular) the anticipated privacy concerns of your users.

Assuming this is a client application running on users' PCs, if this is an "intranet" internal application then it should be quite simple to have the application email the log file to you as the application exits.

This can be quite fun, as sometimes you'll fix the bug before users get around to reporting it.

Alternatively, if you're concerned that the application may crash and the unhandled exception won't be caught properly, you could

  1. On startup, write a registry entry (or dummy file entry, or what-have-you) that marks "application not terminated properly"
  2. On a clean exit, clean up the registry entry (or what-have-you)
  3. On startup, check to see if the registry entry (etc.) exists.

If the marker is present, then you know the application crashed in an un-clean fashion, so you can prompt the user with text e.g. "Last time you ran this program it didn't appear to exit properly. Would you like to send a log of what happened to us so we can try and fix any problem that might have occurred?"

别再吹冷风 2024-10-14 15:39:41

推出您自己的异常处理程序。在您的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);
            }
        }
    }
}

您可以通过从 https://crashreporterdotnet.codeplex.com 获取基于此的崩溃报告库来节省时间

Roll your own exception handler. Use below code in your program.cs class. It will automatically Send mail when exception occurs.

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

You can save your time by getting crash report library based on this one from https://crashreporterdotnet.codeplex.com

北恋 2024-10-14 15:39:41

尝试使用 AppDomain.UnHandledException 和/或 AppDomain.ThreadException

Try to use AppDomain.UnHandledException and/or AppDomain.ThreadException

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文