【发布时间】:2017-02-06 05:09:17
【问题描述】:
我正在编写一个控制台应用程序,用于使用 C# 将集成文件从共享驱动器移动到 linux 服务器。新应用程序工作正常并且完成了它的工作,最近我决定使用配置文件保存属性,如文件路径。
自从我开始使用配置文件后,我收到一个错误“配置系统无法初始化”,没有进一步的细节。以下是我的配置文件中的文本
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<Appsettings>
<Add key="UserName" value="my username" />
<Add key="HostName" value="Ip Add" />
<Add key="Password" value="MyPassword" />
<Add key="SshHostKeyFingerprint" value=" code" />
<Add key="sourcepath" value="file path" />
<Add key="destinationpath" value="file path" />
<Add key="MagentoDestinationpath" value="file path" />
<Add key="filestomove" value="*.csv" />
<Add key="Logfilepath" value="file path" />
</Appsettings>
</configuration>
我已注释掉除下一行之外的所有代码以进行故障排除
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinSCP;
using System.Threading;
using System.IO;
Using System.Configuration;
using System.Collections.Specialized;
namespace Magentogiftcard
{
class Program
{
static void Main(string[] args)
{
string Host = ConfigurationManager.AppSettings.Get("UserName");
Console.WriteLine("Host");
}
}
}
但仍然遇到这个问题。我会给予任何帮助。
问候 贾汉吉尔·希泽
【问题讨论】:
-
您的配置文件格式不正确。请参考链接:stackoverflow.com/questions/6436157/…
-
嗨 Ash,我是 C# 新手,我从下面的 microsoft 链接获得了这种格式。 support.microsoft.com/en-gb/kb/815786 。它使用完全相同的格式
标签: c#