【发布时间】:2018-05-29 10:28:37
【问题描述】:
我不明白需要将什么添加到配置文件或其他任何地方。教程没有显示任何其他内容,我找不到答案。请帮忙。 我删除了所有其他代码,只留下了这部分,因为这是问题所在。 代码如下:
using CommandLine;
using CommandLine.Text;
using System;
using System.Configuration;
using System.Net.Mail;
using System.Text.RegularExpressions;
namespace SendMail {
public class SendMail
{
public static void Main(string[] args)
{
//code that executes just fine and has nothing to do with the MailMessage.
MailMessage mail = new MailMessage();
//unreachable code that can't be at fault because it doesn't reach here.
}
}
这是 App.Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="COMPANYEMAIL" value="*******************" />
<add key="COMPANYEMAILPASSWORD" value="*******" />
</configuration>
此信息稍后在代码中使用,因此它不会成为问题,因为它没有达到我调用它的地步。它很好地传递了代码的第一部分,然后在尝试执行该行时它会中断。有人请帮助我。
【问题讨论】:
-
错误信息是什么?
标签: c# exception configuration mailmessage