カスタム構成を構築しようとしていますが、何らかの理由で機能しません。誰かが私の問題がどこにあるかを見ることができれば幸いです。
コードは次のとおりです。
public class PointServices : ConfigurationSection
{
public static PointServices Get()
{
var t = ConfigurationManager.GetSection("point.Services/xServices") as PointServices;
return t;
}
//<summary>
//Declares a collection element represented in the following configuration sub-section
//<singleInstances> <add .../> </singleInstances>
//</summary>
[ConfigurationProperty("xServices", IsDefaultCollection = true)]
[ConfigurationCollection(typeof(PointServices))]
public PointServicesCollection Services
{
get
{
//var v = base["xServices"];
return (PointServicesCollection) base["xServices"];
}
}
}
public class PointService : ConfigurationElement
{
[ConfigurationProperty("name",IsRequired = true)]
public string Name
{
get
{
return this["name"].ToString();
}
}
[ConfigurationProperty("type", IsRequired = true)]
public string Type
{
get
{
return this["type"].ToString();
}
}
}
ここに設定があります:
<sectionGroup name="point.Services">
<section name="xServices" type="XYZ.Messaging.PointServiceConfiguration.PointServices, XYZ.Point.Messaging" />
</sectionGroup>
...
<point.Services>
<xServices>
<xService>
<add name="XYZService" type="XYZService" />
</xService>
</xServices>
</point.Services>
私が実行しているとき: PointServices.Get()
、私は得ています:
要素 'xService' を認識できません。
次のように xService をセクション定義に追加しようとしましたが、役に立た
<section name="xService" type="XYZPoint.Messaging.PointServiceConfiguration.PointService, Barcap.FIA.Point.Messaging" />
なかったようです。
誰かが何か考えているなら、助けてください!ありがとう