0
我正在經歷和替換應用中的以前的配置策略,以便它更有意義,但它會在應用程序加載時拋出「無法識別的屬性」異常。自定義ConfigurationSection在web.config中引發無法識別的屬性
這裏是我的配置部分
using System.Configuration;
namespace MyApplication
{
public class MyConfigurationSection : ConfigurationSection
{
[ConfigurationProperty("defaultPageIndex", DefaultValue = 1)]
[IntegerValidator(MinValue = 1)]
public int DefaultPageIndex
{
get { return (int)this["defaultPageIndex"]; }
set { this["defaultPageIndex"] = value; }
}
}
}
這裏是web.config中......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="mySettingsGroup">
<section name="mySettings" type="MyApplication.MyConfigurationSection" allowLocation="true" allowDefinition="Everywhere" />
</sectionGroup>
</configSections>
<mySettingsGroup defaultPageIndex="1">
</mySettingsGroup>
</configuration>
的錯誤是Config Error Unrecognized attribute 'defaultPageIndex'
Config Source:
27:
28: <mySettingsGroup defaultPageIndex="1">
29: </mySettingsGroup>
我敢肯定,這愚蠢的東西我只是沒有看到。