如何从 .net 错误对话框发送错误报告?
2008 年,Jeff 写了一篇关于负责任地崩溃的文章。本着这种精神,我尝试在崩溃错误对话框中添加一个“发送错误报告”按钮。这个想法是,用户可以轻松地发送完整的错误报告,其中已经包括版本信息、操作系统信息、堆栈跟踪......这些信息应该放在消息正文或附件文件中。
不幸的是,从 .NET 应用程序发送这样的电子邮件似乎并不简单:
- System.Net.Mail 不是我正在寻找的:我无法确定是否可以在所有环境中建立到 SMTP 服务器的连接,并且我不想将减轻了用户配置本地 SMTP 主机名和端口的负担。相反,我只想使用预先编写的消息启动系统上现有的电子邮件软件。
- 使用操作系统打开“mailto:”URL< /a> 有效,但是对于可以通过这种方式传递的数据量存在令人讨厌的限制。此外,mailto 规范似乎并不真正支持附件。
- mapi.dll 可能会做我想要的事情,如下所示< a href="http://www.codeproject.com/KB/IP/SendFileToNET.aspx" rel="nofollow noreferrer">codeproject 文章,但我在其他地方读到 mapi.dll 与 .NET 根本不兼容,导致随机崩溃。
有没有人找到安全可靠的解决方案来做到这一点?
In 2008 Jeff wrote a post on crashing responsibly. In that spirit, I'm trying to add a "send bug report" button to my crash error dialog. The idea is that the user can easily send a full bug report which already includes version information, OS info, stack trace... This information should be put in the message body or in attachment files.
Unfortunately, sending such an email from a .NET application appears to be non-trivial:
- System.Net.Mail is not what I am looking for: I can't be sure that a connection to an SMTP server can be made in all environments, and I don't want to put the burden of configuring the local SMTP hostname and port on my users. Instead, I just want to launch the existing email software on the system with a precomposed message.
- Using the OS to open a "mailto:" URL works, but there are annoying restrictions to the amount of data that can be passed this way. Also, it appears that attachments are not really supported by the mailto spec.
- mapi.dll would probably do what I want as illustrated by this codeproject article, but I read elsewhere that mapi.dll is fundamentally incompatible with .NET causing random crashes.
Has anyone out there found a safe and reliable solution to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们通过创建一个简单的 WCF Web 服务解决了这个问题,该服务获取堆栈跟踪、压缩日志等,客户端将其发布到它,然后让 Web 服务服务器发送电子邮件。
这样您就不必在客户端拥有 SMTP 身份验证信息,也不必依赖用户通过其电子邮件客户端提交错误报告。
我们现在甚至通过此 Web 服务定期压缩客户端日志并将其提交到后端服务器,并分析这些日志,以便在客户端问题对客户端造成问题之前抢先检测到它们
We have solved this by creating a simple WCF web service that takes the stack trace, zipped logs etc, which the client posts to it and then let the web service server send the email.
This way you don't have to have the SMTP authentication information on the client side, nor do you have to rely on the user to submit the error report via their email client.
We're now even zipping and submitting client side logs periodically to the backend server via this webservice and analyze those logs to preemptively detect any client side issues before they become problematic to the client
一种快速方法是设置您的服务器以通过 PHP fe 接收信息。创建一个 ErrorReport.php 并尝试使用包含在 base64 包中的所有信息来调用它。
这“仅”需要端口 80 上的互联网访问,该端口很可能可用。从那里您可以处理信息并将其传递到数据库 fe 中。
A quick way would be to set up your server to receive the information via PHP f.e. . Create an
ErrorReport.php
and try to call it with every information you have wrapped in a base64 package.This 'only' needs Internet-Access on Port 80, which is most likely available. From there you can process the information and pass it on into a database f.e. .
您可以 - 当使用您自己的兼容服务器时 - 只需创建一个类似“telnet”的套接字结构即可将数据直接发布到您的服务器中。
像这样的东西:http://www.csharphelp。 com/2007/07/sending-email-with-c-using-smtp/
You could - when using your own compatible server - just create a "telnet" like socket structure to post the data directly into your server.
Something like this: http://www.csharphelp.com/2007/07/sending-email-with-c-using-smtp/