我有一个控制台.Net应用程序,它通过传递一个参数的批处理文件执行。我正在努力将此设置迁移到另一台服务器,由于某种原因我在新服务器上遇到错误,似乎表明无法读取ApplicationSettings文件。两台服务器上的设置对我来说都是一样的,权限看起来也还可以。两个服务器都是Win 2008.任何建议都表示赞赏。
以下是详细信息:
批处理文件:
auto-batch-processes.exe 2
自动批处理processes.exe.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings file="Config\ApplicationSettings.config" />
<connectionStrings configSource="Config\ConnectionStrings.config" />
<startup>
.............
配置\ ApplicationSettings.config
<appSettings>
<add key="log4net.Internal.Debug" value="true"/>
<add key="Environment" value="LIVE" />
......
<add key="Email" value="blabla@blabla.com"/>
......
</appSettings >
执行批处理文件后,我收到以下错误
D:\Apps\Auto-Batch-Processes>auto-batch-processes.exe 3
Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: address
at System.Net.Mail.MailAddress..ctor(String address, String displayName, Enco
ding displayNameEncoding)
at auto_batch_processes.Managers.NotificationManager..ctor() in c:\Workspace\
MSI\Auto Batch Processes\auto-batch-processes\Managers\NotificationManager.cs:li
ne 25
at auto_batch_processes.AbpBase..ctor() in c:\Workspace\MSI\Auto Batch Proces
ses\auto-batch-processes\AbpBase.cs:line 18
at auto_batch_processes.JobProcessor..ctor() in c:\Workspace\MSI\Auto Batch P
rocesses\auto-batch-processes\JobProcessor.cs:line 12
at auto_batch_processes.Program.Main(String[] jobs) in c:\Workspace\MSI\Auto
Batch Processes\auto-batch-processes\Program.cs:line 21
这里的应用程序代码片段代表它可能会爆炸的地方:
public NotificationManager()
{
_fromAddress = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["Email"]);
_environment = System.Configuration.ConfigurationManager.AppSettings["Environment"];
...........
public MailAddress(string address, string displayName, Encoding displayNameEncoding) {
if (address == null){
throw new ArgumentNullException("address");
}
if (address == String.Empty){
throw new ArgumentException(SR.GetString(SR.net_emptystringcall,"address"), "address");
}