當我嘗試讀取我的設置時出現錯誤。我知道我在某處寫錯了。由於我找不到太多信息,單獨完成該程序。設置xml StackOverflowException錯誤
//設置讀碼
public static class proSave
{
public static propertyClass oku
{
get
{
XmlSerializer serialize = new XmlSerializer(typeof(propertyClass));
var stream = new StreamReader("settings.xml");
return (propertyClass)serialize.Deserialize(stream);
}
}
}
設置應用代碼
namespace property
{
[Serializable]
public class propertyClass
{
private string _serverName = proSave.oku.serverName;
[Description("Server Bağlantı Adı"), Category("Server Setting")]
public string serverName { get { return _serverName; }}
private string _databaseName = proSave.oku.serverName;
[Description("Server Bağlantısı Dosya Adı"), Category("Server Setting")]
public string databaseName { get { return _serverName; } }
private string _user = proSave.oku.user;
[Description("Server Bağlantısı kullanıcı adı"), Category("Server Setting")]
public string user { get { return _user; } }
private string _password = proSave.oku.password;
[Description("Server Bağlantısı kullanıcı şifresi"), Category("Server Setting")]
public string password { get { return _password; } }
private int _gridHeight = proSave.oku.gridHeight;
[Description("Grid Hücre Yükseklik Ayarı \nFormlar Yenilendiğinde etkinleştirilecektir."), Category("Grid Ayarları")]
public int gridHeight { get { return _gridHeight; } }
}
}
XML:異常
<?xml version="1.0" encoding="utf-8"?>
<propertyClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<serverName>1</serverName>
<databaseName>Kadir</databaseName>
<user>as</user>
<gridHeight>40</gridHeight>
</propertyClass>
你得到的錯誤是什麼? – leppie
您能提供一些有關您的settings.xml文件的錯誤和內容的詳細信息嗎? – abrown