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 7400465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:15:15+00:00 2026-05-29T04:15:15+00:00

I have created one class that directly map to ConfigSection of web. config. My

  • 0

I have created one class that directly map to ConfigSection of web. config. My class definition is given below :

public class myConfiguration: ConfigurationSection
{
    public myConfiguration()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    [ConfigurationProperty("fileName", IsRequired = true)]
    public string FileName
    {
        get { return this["fileName"] as string; }
    }


    [ConfigurationProperty("rootNode", IsRequired = true)]
    public string RootNode
    {
        get { return this["rootNode"] as string; }
    }

    [ConfigurationProperty("childNode", IsRequired = true)]
    public string ChildNode
    {
        get { return this["childNode"] as string; }
    }

    [ConfigurationProperty("comparableAttributes", IsRequired = true)]
    public string ComparableAttributes
    {
        get
        { return this["comparableAttributes"] as string; }
    }
}

I have created section in web.config file as below :

    <configSections>
    <section name="myConfigDemo" type="myConfiguration"/>
    </configSections>

Then i have used this section as

  <myConfigDemo fileName="myXml.xml" rootNode="world" childNode="country" comparableAttributes="id, population">

  </myConfigDemo>

Now the problem is How can I assign fileName = "anotherFile.xml" at runtime ? I have tried

   [ConfigurationProperty("fileName", IsRequired = true)]
    public string FileName
    {
        get { return this["fileName"] as string; }
        set {
            string str = this["fileName"] as string; 
              str  = value; }
    }

But my Visual Studio make my pc hang wen i use code above ! i Know the property is readonly when u use only get but set makes my pc hang !!! What can i do to change filename runtime ?

  • 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-05-29T04:15:17+00:00Added an answer on May 29, 2026 at 4:15 am

    There are .net classes designed for more accurate accessing of almost everything that can be found in .config files (and not just appSettings or ConnectionStrings elements); documentation here: http://msdn.microsoft.com/en-us/library/x1et32w6.aspx

    I’m not sure if they provide ways to change values, though (take a look). However, a gotcha: config files are designed to configure the app at startup; in other words, the app reads the file when it starts, and then again if it’s changed manually or by a process. With asp.net apps, this means that the application will automatically restart (by default; IIS setting).

    If you really want to reconfigure the app at runtime, you’ll force it to restart every time you SAVE the file. So, in that case, write code to make all changes in memory (e.g. by using xml classes), then save all at once.

    There is a setting within app-pool to disable auto-restarting on config changes; however, if you do this, the app will NOT restart when you make config changes, and you’ll have to write code to restart it for it to pick up those changes.

    This class might be your friend, if you want to automatically serialize your custom config class to xml element: http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx

    I hope that helps.

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

Sidebar

Related Questions

I have created one class as public class FormActivity extends Activity { TextView tv
I have a class that creates a calendar. One of the methods finds the
In my app i have created one custom class for Label.Now i want to
i have one problem with handling list,i have three class named as UserInf,userData,userProcess,i created
I have created one service in my grails application. in that service 25 methods
i have created one image but problem is that when i save image from
I have created an interface that my DbContext class implements, this enables me to
Qt creator has option to promote one widget to customly created class that derives
my problem is a simple one. I have a class template that holds a
I have crated a class which extends the ListFragment . I have one button

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.