c# - 如何将附加文件附加到 NBug
问题描述
我正在使用 NBug 从我的 WPF 应用程序发送报告,但我想将客户端特定文件附加到电子邮件中。这是我的代码:
AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
Application.Current.DispatcherUnhandledException += NBug.Handler.DispatcherUnhandledException;
if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory))
{
var stream = File.Create(AppDomain.CurrentDomain.BaseDirectory + FileNames.FILE_NAME_MACHINE_INFO);
stream.Close();
TextWriter tw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + FileNames.FILE_NAME_MACHINE_INFO);
tw.WriteLine("The very first line!");
tw.Close();
}
NBug.Settings.AdditionalReportFiles.Add(AppDomain.CurrentDomain.BaseDirectory + FileNames.FILE_NAME_MACHINE_INFO);
问题是,我得到了一个例外
NBugError: An exception occurred while submitting bug report with Mail. Check the inner exception for details.
Exception: System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Security._SslStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Mime.EightBitStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Base64Stream.FlushInternal()
at System.Net.Base64Stream.Close()
at System.Net.Mime.MimePart.Send(BaseWriter writer, Boolean allowUnicode)
at System.Net.Mime.MimeMultiPart.Send(BaseWriter writer, Boolean allowUnicode)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at NBug.Core.Submission.Web.Mail.Send(String fileName, Stream file, Report report, SerializableException exception)
at NBug.Core.Submission.Dispatcher.EnumerateDestinations(Stream reportFile, ExceptionData exceptionData)
有任何想法吗?我究竟做错了什么?
谢谢
解决方案
我找到了答案。我将 MiniDump Type 设置为 Full 并且 .zip 文件变得超过 100MB,您无法使用 gmail 发送这么大的文件。当我将 MinDump 类型设置为 Tiny 时,它解决了问题
推荐阅读
- python - 在python中导入多个excel文件,操作,然后在同一个目录下导出多个文件
- docker - docker --cache-from 是使用本地还是远程注册表?
- laravel - 如何减少laravel中的数据大小以进行ajax响应?
- javascript - 如何使用 Vue.js 更改 NUXT.js 中的元素
- html - 如何使用常规文本输入上的清除“x”按钮获取搜索输入的行为?
- android - 添加隐藏/显示编辑文本
- typescript - 如何使 VSCode 自动导入在 lerna-yarn-typescript 项目中工作?
- c++ - 使用 Simd::Motion::Detector 检测小型快速物体
- sql - 使用 has_many 列出所有没有父类别的条目,并通过连接表关系
- angular - 尝试接受阅读后的服务