我寫的共享驅動器移動整合文件使用C#。新的應用程序工作正常,並做其工作的Linux服務器控制檯應用程序,最近我已經決定使用配置文件保存喜歡的文件路徑屬性。配置錯誤C#應用程序配置
既然我已經使用配置文件,我得到一個錯誤「配置系統初始化失敗」,沒有進一步的細節開始。下面是我的配置文件中的文本
<?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");
}
}
}
但仍然得到這個問題。我會appriciate任何幫助。
認爲 賈漢吉爾Khizer
您的配置文件不正確的格式。請參考鏈接: http://stackoverflow.com/questions/6436157/configuration-system-failed-to-initialize – Ash
灰您好,我是新來的C#,我有從下面的Microsoft鏈接這種格式。 https://support.microsoft.com/en-gb/kb/815786。它是用來一模一樣的格式 – Jahangir