0

カスタム構成を構築しようとしていますが、何らかの理由で機能しません。誰かが私の問題がどこにあるかを見ることができれば幸いです。

コードは次のとおりです。

    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" />なかったようです。

誰かが何か考えているなら、助けてください!ありがとう

4

2 に答える 2

1

また、xService には別の指定子が必要です

<sectionGroup name="point.Services">          
  <sectionGroup name="xServices">          
    <section name="xService" 
      type="XYZ.Messaging.PointServiceConfiguration.PointServices, XYZ.Point.Messaging" />  
  </sectionGroup name="xServices">         
</sectionGroup>
于 2009-11-19T22:51:37.833 に答える
0

xServices は、セクションではなく、セクション グループにする必要があります。また、xService はセクションとして定義する必要があります。

于 2009-11-19T22:47:24.787 に答える