Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8556543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:22:34+00:00 2026-06-11T15:22:34+00:00

http://msdn.microsoft.com/en-us/library/system.configuration.configurationpropertyattribute.aspx Immutable types as configuration properties In the QueueConfiguration class below QueueID returns an

  • 0

http://msdn.microsoft.com/en-us/library/system.configuration.configurationpropertyattribute.aspx

Immutable types as configuration properties

In the QueueConfiguration class below QueueID returns an int. When I run the code I get this error when accessing the getter:
The value of the property ‘queueID’ cannot be parsed. The error is: Unable to find a converter that supports conversion to/from string for the property ‘queueID’ of type ‘Int32’.

If I change QueueID to return a string it works fine. Note in the microsoft link cited above that a typeconverter is not needed to return the port property as an int. I’m suppose I’m missing something obvious……

public class QueueConfiguration : ConfigurationSection
{
    [ConfigurationProperty("queueID", DefaultValue = (int)0, IsKey = true, IsRequired = true)]        
    public int QueueID
    {
        get 
        {
            return (int)this["queueID"];
        }
        set { this["queueID"] = value; }
    }

    [ConfigurationProperty("queueName", DefaultValue = "", IsKey = false, IsRequired = true)]
    public string QueueName
    {
        get { return (string)this["queueName"]; }
        set { this["queueName"] = value; }
    }
}


public class QueueConfigurationCollection : ConfigurationElementCollection
{
    internal const string PropertyName = "QueueConfiguration";

    public override ConfigurationElementCollectionType CollectionType
    {
        get
        {
            return ConfigurationElementCollectionType.BasicMapAlternate;
        }
    }

    protected override string ElementName
    {
        get
        {
            return PropertyName;
        }
    }

    protected override bool IsElementName(string elementName)
    {
        return elementName.Equals(PropertyName, StringComparison.InvariantCultureIgnoreCase);
    }


    public override bool IsReadOnly()
    {
        return false;
    }


    protected override ConfigurationElement CreateNewElement()
    {
        return new QueueConfiguration();
    }

    protected override object GetElementKey(ConfigurationElement element)
    {
        return ((QueueConfiguration)(element)).QueueID;
    }

    public QueueConfiguration this[int idx]
    {
        get
        {
            return (QueueConfiguration)BaseGet(idx);
        }
    }
}

public class QueueConfigurationSection : ConfigurationSection
{
    [ConfigurationProperty("Queues")]
    public QueueConfigurationCollection Queues
    {
        get { return ((QueueConfigurationCollection)(this["Queues"])); }
        set { this["Queues"] = value; }
    }
}

Here is my App.config (for some reason this site refuses to display the configSection portion of app config so I’ll do my best to break it:

<configSections>
 <section name="QueueConfigurations" type="STPMonitor.Common.QueueConfigurationSection, STPMonitor"/> 
</configSections>

<QueueConfigurations>
<Queues>
  <QueueConfiguration queueID="1" queueName="One"></QueueConfiguration>
  <QueueConfiguration queueID="2" queueName="Two"></QueueConfiguration>
</Queues>
</QueueConfigurations>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:22:36+00:00Added an answer on June 11, 2026 at 3:22 pm

    Well, I just copy-pasted and tried your code and it works without any errors. My read code was:

    var section = ConfigurationManager.GetSection("QueueConfigurations") as QueueConfigurationSection;
    var queueId = section.Queues[0].QueueID;
    Console.Out.WriteLine("queueId = {0}", queueId);
    

    and it prints queueId = 1

    here is gist: https://gist.github.com/b8499dcfa7456624f073

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been looking into the Timer class ( http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx ), but the thing about
I'm reading about the CallContext class ( http://msdn.microsoft.com/en-us/library/system.runtime.remoting.messaging.callcontext.aspx ). The documentation says something about
According to http://msdn.microsoft.com/en-us/library/system.windows.forms.linklabel.aspx , the LinkLabel class has both a Click event inherited from
http://msdn.microsoft.com/en-us/library/system.double.epsilon.aspx If you create a custom algorithm that determines whether two floating-point numbers can
From http://msdn.microsoft.com/en-us/library/system.math.pow.aspx int value = 2; for (int power = 0; power <= 32;
According to MSDN ( http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autosize.aspx ), there's a note about Label 's AutoSize property:
From the documentation here http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.login.layouttemplate.aspx i had customized the user interface of login control
Using techniques as hinted at in: http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.callbackcontract.aspx I am implementing a ServerPush setup for
I want to connect to a URL with the socket method ( http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=VS.96).aspx );
So, this example comes right from MSDN. http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.readelementcontentasbase64.aspx Pretty much the only thing I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.