Tech Off Thread

5 posts

Configuration Management Application Block Problems..

Back to Forum: Tech Off
  • User profile image
    JParrish

    I have been trying to implement the Configuration Management Application Block and I am running into some trouble. If anyone has experience with this block I would appreciate a nudge in the right direction.

    I am getting the following error when I attempt to write to configuration:

    ============
    An unhandled exception of type 'System.Configuration.ConfigurationException' occurred in microsoft.applicationblocks.configurationmanagement.dll

    Additional information: Section 'TarponCoreConfig' not defined on the configuration file. Check the /configuration/configSections/section node in the application config file (assemblyfilename.config). This node must be like <section name="XmlConfig" type="WinApp.CustomSectionHandler,WinApp" />.
    ============

    Which confuses me. I have traced the problem down to an XPath expression used to retrieve the config section, but it doesnt seem right to me. The Xpath expression is "/configuration/configSections/section[@name='TarponCoreConfig']"

    That path doesnt make sense from the configurations I have seen in the documentation. From the reading I have done I have configured my app.config as such:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <configSections>
      <section name="applicationConfigurationManagement" type="Microsoft.ApplicationBlocks.ConfigurationManagement.ConfigurationManagerSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
     </configSections>
     <applicationConfigurationManagement>
      <configSection name="TarponCoreConfig">
       <configProvider
        assembly="Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
        type="Microsoft.ApplicationBlocks.ConfigurationManagement.Storage.XmlFileStorage"
        path="../../TarponConfig.xml"
        signed="false"
        encrypted="false" />
      </configSection>
     </applicationConfigurationManagement>
    </configuration>


    and for the configuration file "TarponConfig.xml" I have configured it as such:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <TarponCoreConfig>
     </TarponCoreConfig>
    </configuration>


    Any help is appreciated.

  • User profile image
    jwanagel

    You need in your <configSections> a <section> tag for "TarponCoreConfig".  This is where you specify your section handler class for your TarponCoreConfig.  So it needs to look something like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
     <configSections>
      <section name="applicationConfigurationManagement" type="Microsoft.ApplicationBlocks.ConfigurationManagement.ConfigurationManagerSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
      <section name="TarponCoreConfig" type="MySectionHandler,MySectionHandler, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null" />
     </configSections>
     <applicationConfigurationManagement>
      <configSection name="TarponCoreConfig">
       <configProvider
        assembly="Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
        type="Microsoft.ApplicationBlocks.ConfigurationManagement.Storage.XmlFileStorage"
        path="../../TarponConfig.xml"
        signed="false"
        encrypted="false" />
      </configSection>
     </applicationConfigurationManagement>
    </configuration>

    Also, check out the workspace : http://www.gotdotnet.com/Community/Workspaces/Workspace.aspx?id=01875f69-9358-437b-a8ae-fa4bf2e3080f

  • User profile image
    JParrish

    Ah! Thanks very much. I will go check out the workspace, I imagine most my problems have been had before =)

  • User profile image
    JParrish

    I just posted this in the workspace forum, but since I'm not sure how responsive people are there I wanted to copy it here.

    I am getting the following error when I try and serialize a Hashtable that I have added a strongly typed collection object to:

    An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll

    Additional information: There was an error generating the XML document.


    My collection is defined as follows:

     [Serializable]
     public class ArtifactServRefCollection : CollectionBase
     {
      public ArtifactServRefCollection()
      {
       //..
      }

      public void Add(ArtifactServiceReference value)
      {
       List.Add(value);
      }

      public void Insert(int index, ArtifactServiceReference value)
      {
       List.Insert(index,value);
      }

      public ArtifactServiceReference this[int index]
      {
       get
       {
        return List[index] as ArtifactServiceReference;
       }
      }
     }

    And my ArtifactServiceReference class is simple enough, contains two properties, and is serializable.

    I have tried stepping into the code, and so far it appears that the StringWriter is containing only a portion of what the full XML representation of my object would be. Are there any specifics that I need to be aware of when creating custom objects for insertion into a hashtable that is to be serialized with this block? Right now, I am a little frustrated at my inability to determine exactly why I am having a problem in the XmlSerializer class (a core framework class). Any help is greatly appreciated.

  • User profile image
    JParrish

    I did some reading and it seems that the following from a post that referenced an MS document will most likely be my solution.

    "Note The XmlSerializer gives special treatment to classes that
    implement IEnumerable or ICollection. A class that implements
    IEnumerable must implement a public Add method that takes a single
    parameter. The Add method's parameter must be of the same type as is
    returned from the Current property on the value returned from
    GetEnumerator, or one of that type's bases. A class that implements
    ICollection (such as CollectionBase) in addition to IEnumerable must
    have a public Item indexed property (indexer in C#) that takes an
    integer, and it must have a public Count property of type integer. The
    parameter to the Add method must be the same type as is returned from
    the Item property, or one of that type's bases. For classes
    implementing ICollection, values to be serialized will be retrieved
    from the indexed Item property, not by calling GetEnumerator."

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.