落红护花 发表于 2021-8-24 11:55:00

【原创】C#错误反馈模块生成器

<i class="pstatus"> 本帖最后由 落红护花 于 2021-8-24 11:55 编辑 </i><br />
<br />
<font face="微软雅黑"><font size="4">前方高能!!<img src="https://static.52pojie.org/static/image/smiley/laohu/laohu33.gif" smilieid="997" border="0" alt="" />此帖适用于C#初学者和运用C#的软件开发大佬。<br />
<br />
在写try...catch时,大家是不是都这样敷衍了事?<br />
<div style="padding:15px 0;"><div style="font-size:12px;"> <em class="viewsource" style="cursor:pointer;font-size:12px;color:#369 !important;">纯文本查看</em> <em class="copycode" style="cursor:pointer;font-size:12px;color:#369 !important;">复制代码</em></div><pre class="brush: csharp; gutter: true">            try
            {
                //你的代码
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }</pre></div></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">谁不想来个这样反馈界面的呢</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325896" aid="2325896" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/110714q0v80dozfe6o8pmo.png" file="https://attach.52pojie.org/forum/202108/24/110714q0v80dozfe6o8pmo.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="551" id="aimg_2325896" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325896_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>msedge_XQYNh4VFfa.png</strong> <em class="xg1">(288.03 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTg5Nnw0NDUyYWU2OHwxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:07 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">那么C#错误反馈模块生成器值得你拥有,因涉及到账号密码,让坛友们用的放心,本软件开源<img src="https://static.52pojie.org/static/image/smiley/laohu/laohu3.gif" smilieid="993" border="0" alt="" /></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">成功调用示例</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325904" aid="2325904" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/111048k9sie1o9o7xfo3od.png" file="https://attach.52pojie.org/forum/202108/24/111048k9sie1o9o7xfo3od.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="1080" id="aimg_2325904" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325904_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>devenv_SlCNreI5Ua.png</strong> <em class="xg1">(85.87 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTkwNHxmMzBkNjA4MXwxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:10 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325906" aid="2325906" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/111111msvfvua2goukcuee.png" file="https://attach.52pojie.org/forum/202108/24/111111msvfvua2goukcuee.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="1080" id="aimg_2325906" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325906_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>msedge_jmqAVH4jEG.png</strong> <em class="xg1">(280.42 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTkwNnwwODQwNzYxN3wxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:11 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325905" aid="2325905" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/111108h5n221yszm98m181.png" file="https://attach.52pojie.org/forum/202108/24/111108h5n221yszm98m181.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="1080" id="aimg_2325905" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325905_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>msedge_uyljwceSPm.png</strong> <em class="xg1">(333.32 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTkwNXw5ZGEyYjQ5OXwxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:11 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="5"><font color="#ff0000">事前准备:</font></font></font><br />
<font face="微软雅黑"><font size="5"><font color="#ff0000"><br />
</font></font></font><br />
<font face="微软雅黑"><font size="4">两个邮箱,一个发送,一个接收,发送端需要开启<font style="color:rgb(21, 21, 21)"><font style="background-color:rgb(249, 249, 249)">IMAP/SMTP服务,然后记住授权密码(outlook无需授权密码,只需要登陆密码),之后需要用到(目前发送端仅支持163,126,QQ,outlook,因为某些你懂的的原因,Gmail和hotmail发不了)</font></font></font></font><br />
<font face="微软雅黑"><font size="4">强烈推荐使用新注册邮箱作为发送端,因为涉及到账号密码,虽然被盗的几率很小,但是为安全着想嘛</font></font><br />
<font face="微软雅黑"><font size="4">接收端使用任何邮箱都可以</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="5"><font color="#ff0000">食用:</font></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325900" aid="2325900" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/110930f4c2akz4kkzsjp70.png" file="https://attach.52pojie.org/forum/202108/24/110930f4c2akz4kkzsjp70.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="883" id="aimg_2325900" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325900_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>ErrorSenderMaker_oV0PWpjL75.png</strong> <em class="xg1">(26.43 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTkwMHxiNTEzYmZkOHwxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:09 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4">打开软件,先选择发送端邮箱类型(额,别的邮箱我会逐渐测试,目前仅成功四个,敬请谅解)</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">填写发送端和接收端的邮箱地址,这里说一下,既然发送接收都用自己的邮箱,为什么还需要用户填写邮箱呢</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">因为使用程序发送邮件需要开启IMAP/SMTP,我们控制不了用户的邮箱设置,所以需要使用我们自己的邮箱作为发送端</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">然后将刚才获取的授权密码填入,注:outlook邮箱发送端填写登陆密码即可</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">提示语可以自己填写,如留空则显示默认,就是上面的成功示例显示的</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325899" aid="2325899" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/110928b87cw4j7dlojj48l.png" file="https://attach.52pojie.org/forum/202108/24/110928b87cw4j7dlojj48l.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="1080" id="aimg_2325899" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325899_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>explorer_zlvBiS2aJ2.png</strong> <em class="xg1">(168.66 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTg5OXxiZTlhMGZmOXwxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:09 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">完成之后会生成你的代码,可以选择程序编译为dll自定义控件</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325898" aid="2325898" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/110926qdb4rowiwfst88fo.png" file="https://attach.52pojie.org/forum/202108/24/110926qdb4rowiwfst88fo.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="1080" id="aimg_2325898" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325898_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>devenv_lsgPF5PAUe.png</strong> <em class="xg1">(177.75 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTg5OHwwN2JkZDVmM3wxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:09 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">
<ignore_js_op>

<img id="aimg_2325917" aid="2325917" src="https://static.52pojie.org/static/image/common/none.gif" zoomfile="https://attach.52pojie.org/forum/202108/24/114108i0xgex2b6caan0hc.png" file="https://attach.52pojie.org/forum/202108/24/114108i0xgex2b6caan0hc.png" class="zoom" onclick="zoom(this, this.src, 0, 0, 0)" width="883" id="aimg_2325917" inpost="1" />

<div class="tip tip_4 aimg_tip" id="aimg_2325917_menu" style="position: absolute; display: none" disautofocus="true">
<div class="xs0">
<p><strong>ErrorSenderMaker_tWZCElO08f.png</strong> <em class="xg1">(52.38 KB, 下载次数: 0)</em></p>
<p>
<a href="https://www.52pojie.org/forum.php?mod=attachment&aid=MjMyNTkxN3w0MmQ4YzBhNHwxNjMwMzM0NDM5fDQ1MjE1NHwxNDk5Mjg2&nothumb=yes" target="_blank">下载附件</a>

</p>

<p class="xg1 y">2021-8-24 11:41 上传</p>

</div>
<div class="tip_horn"></div>
</div>

</ignore_js_op>
</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">如果编译后没有显示“已成功编译”字样,需自行使用vs编译,编译成功后是个dll文件</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">将dll直接拖入vs中的C#工具箱,新建一个窗体,将工具箱中的“ErrorSender”拖到窗体上,下面是调用示例</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4"><div style="padding:15px 0;"><div style="font-size:12px;"> <em class="viewsource" style="cursor:pointer;font-size:12px;color:#369 !important;">纯文本查看</em> <em class="copycode" style="cursor:pointer;font-size:12px;color:#369 !important;">复制代码</em></div><pre class="brush: csharp; gutter: true">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ErrorTest
{
    public partial class Form1 : Form
    {
      public Form1()
      {
            InitializeComponent();
      }
      int test;
      private void Form1_Load(object sender, EventArgs e)
      {

      }

      private void button1_Click(object sender, EventArgs e)   //button1点击事件
      {
            try
            {
                test = Convert.ToInt32(textBox1.Text);                //因textBox1中没有字符,转换失败报错
            }
            catch (Exception ex)
            {
                Form2.reason = ex.ToString();                            //错误原因
                Form2 form2 = new Form2();
                form2.ShowDialog();                                          //弹出Form2错误反馈
            }
      }
    }
}
</pre></div></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4"></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">默认用户界面是不显示后台错误原因的,只会在邮件中给作者发送,如需要显示可以自己修改一下或留言给我,我给你添加</font></font><br />
<font face="微软雅黑"><font size="4">因为程序涉及到账号密码,这个就开源了吧,然后有任何问题和建议请留言,感谢支持<img src="https://static.52pojie.org/static/image/smiley/laohu/laohu23.gif" smilieid="986" border="0" alt="" /></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">大佬们可以看看源码,如果检测安全的话帮忙留个言告诉大家一下</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">感觉程序哪里不好也可以自己改改源码增添新功能,欢迎留言反馈<img src="https://static.52pojie.org/static/image/smiley/laohu/laohu39.gif" smilieid="1003" border="0" alt="" /></font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">不推荐使用含有重要文件的邮箱作为发送端,出现任何损失和问题和作者无关</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">下载地址:</font></font><br />
<font face="微软雅黑"><font size="4"><br />
</font></font><br />
<font face="微软雅黑"><font size="4">成品:<a rel="nofollow noopener" href="https://chenyilin.lanzoui.com/iTYREt2qsxi" target="_blank">https://chenyilin.lanzoui.com/iTYREt2qsxi</a></font></font><br />
<font face="微软雅黑"><font size="4">源码:<a rel="nofollow noopener" href="https://chenyilin.lanzoui.com/iYb2dt2qvzi" target="_blank">https://chenyilin.lanzoui.com/iYb2dt2qvzi</a></font></font><br />
<font face="微软雅黑"><font size="4">示例:<a rel="nofollow noopener" href="https://chenyilin.lanzoui.com/iNu4Et3bwyj" target="_blank">https://chenyilin.lanzoui.com/iNu4Et3bwyj</a></font></font><br />
<font face="微软雅黑"><font size="4">示例源码:<a rel="nofollow noopener" href="https://chenyilin.lanzoui.com/iSGJUt3bube" target="_blank">https://chenyilin.lanzoui.com/iSGJUt3bube</a></font></font>

dplxin 发表于 2021-8-24 13:40:00

友情提醒,这个没发 大面积使用, 你客服全国各地的话, 发送邮箱一下子就异常冻结了哦

Bell520vae 发表于 2021-8-24 15:03:00

如果要起到通知作者的方式。用企业微信的bot通知。。只需要发送一个get请求就可以通知到我了。。免得搞邮箱。

kele0208 发表于 2021-8-24 12:14:00

感谢分享。

yoyoma211 发表于 2021-8-24 12:40:00

进来学习下,感谢科普<img src="https://static.52pojie.org/static/image/smiley/laohu/laohu39.gif" smilieid="1003" border="0" alt="" />

fengyun005 发表于 2021-8-24 14:01:00

收藏学习,谢谢分享

icysky0605 发表于 2021-8-24 14:17:00

这个真心不错,感谢

konglingpo 发表于 2021-8-24 14:23:00

支持原创,感谢分享。

DarkMarshal 发表于 2021-8-24 14:43:00

加油,不错

yunruifuzhu 发表于 2021-8-24 14:52:00

实不相瞒,这个界面确实看了不想要。建议加入个UI控件
页: [1] 2
查看完整版本: 【原创】C#错误反馈模块生成器