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

  • Home
  • SEARCH
  • 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 7811701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:15:55+00:00 2026-06-02T04:15:55+00:00

I am reading articles, forum posts about applicationSettings for almost a week now. In

  • 0

I am reading articles, forum posts about applicationSettings for almost a week now.

In almost every thread there was someone that appears to have correctly pointed out that the class libraries cannot have config files when deployed and their applicationSettings configured at design must be specified/merged in the executable.exe.config configuration file of the application that host/consumes the dll.

Not necessarily true.

You can but you don’t need to merge them class library settings unless you want to provide the user with a way to “overwrite” the default values – the ones that are specified using the DefaultValueAttribute hard coded in the assembly.

So, for a very simple, practical example. Let’s use VB.NET
1. I created a Class Library project called ClassLibrary.
2. Showing all files, expand MyProject, double click Settings.settings.
3. Adding a setting called Message, application scoped whose value is “Hello!”.
4. Create a property in Class1.vb (the automatically added class)

Public Class Class1

    Public Shared ReadOnly Property Message As String
        Get
            Return My.Settings.Message
        End Get
    End Property

End Class
  1. Create a VB WinForms project and call it WinForm.
  2. Add a reference to the ClassLibrary project.
  3. Add a button to the already created Form1 and double click on it.
    8 Add the some code to the the Button1_Click handler. Should look like this.

    Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        MessageBox.Show(ClassLibrary.Class1.Message)
    End Sub
    

    End Class

  4. Have WinForm “Set as Startup project”

Now, while in the IDE everything works beautifully. Run the solution and you’ll get the expected Hello! when you press the button. If you go and change the setting in the app.config of the library to say “Good bye!” and you run the solution again you get a “Good bye!”

However, right click on the WinForm project and “Open in Explorer” and get to the Debug folder. There’s no WinForm.exe.config file yet. Let’s create one quickly.
Switch back to VS and while the WinForm project is selected click to Show All Files.
Expand MyProject, open Settings.settings, create a setting (doens’t matter what) and save.
There we go, an App.config was created and if I build this solution, the Debug folder will contain a WinForm.exe.config.

Tell me how I merge my Message setting from the class library config

<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="ClassLibrary.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>

    <applicationSettings>
        <ClassLibrary.My.MySettings>
            <setting name="Message" serializeAs="String">
                <value>Hello!</value>
            </setting>
        </ClassLibrary.My.MySettings>
    </applicationSettings>
</configuration>

into the WinForm’s config

<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="WinForm.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" />
    </startup>
    <applicationSettings>
        <WinForm.My.MySettings>
            <!--<setting name="A" serializeAs="String">
                <value>A</value>
            </setting>-->
        </WinForm.My.MySettings>
    </applicationSettings>
</configuration>

so I can change the Message setting’s value in the WinForm.exe.config to something else and the application will display this new value overriding the DefaultValueAttribute.

  • 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-02T04:15:58+00:00Added an answer on June 2, 2026 at 4:15 am

    I have done some research lately for this applicationSettings problem.
    I found two relatively convenient ways of doing what I was asking for.
    I put my thoughts about it together and wrote a blog entry here.

    1. assemblies that your main assembly depend on can and will use settings you define in their individual projects but only during development just because they are build on the fly and contain whatever values you set last time. However when you deploy and think that you can place .config for each assembly they won’t work if you expect to change a setting’s value and have that reflected at runtime, that’s because the last values are set as default values and are hardcoded in.
    2. So you have to either move all your settings to the appSettings in the .config file of the main assembly and inject them at runtime as needed to the assemblies needing them (passing them as arguments).
    3. Otherwise let’s say these are your config files while in development:

    ClassLibrary.dll.config2

    Winform.exe.config3

    For deployment you will have to create a configuration section in the main config file and point to

    Modified Winform.exe.config

    your modified "ClassLibrary.dll.config":

    enter image description here

    You don’t have to point to external files though, the config sections declarations can point to their definitions further down in the main config file like this.

    internalsections

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

Sidebar

Related Questions

When reading articles about Java threads, I often notice the expression: current thread is
There seems to have a buzz around the Lightswitch application framework. Reading some posts/forums/articles
I am reading articles about css. I found out that many of writers suggest
After reading some articles about XSS I have incorporated HTMLPurifier into my zend framework
I am trying to express what I understood from reading some articles about dom0
I've been reading articles at raywenderlich.com and saw that they show an XIB being
Reading an article about HTML5, it occurs to me that while placeholders are incredibly
I have been reading articles about asynchronous messaging between clients using MVC3 and the
I've been reading articles about RESTful services for a while, and I understand the
I've created a simple app for reading articles, which creates posts with the following

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.