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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:15:27+00:00 2026-05-17T19:15:27+00:00

Early, I have defined custom section in Console application and it works fine. But

  • 0

Early, I have defined custom section in Console application and it works fine. But now I want to move some of functionality to the library. But, unfortunately, I cannot. Because now my custom section was defined as null.

The simple console application include next code:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            NotificationsConfigurationSection section
  = NotificationsConfigurationSection.GetSection();
            string emailAddress = section.EmailAddress;
            Console.WriteLine(emailAddress);
            Console.Read();
        }
    }
}

The file with custom configuration which is situated in the separate library include next code:

namespace ClassLibrary1
{
    public class NotificationsConfigurationSection : ConfigurationSection
    {
        private const string configPath = "cSharpConsultant/notifications";
        public static NotificationsConfigurationSection GetSection()
        {
            return (NotificationsConfigurationSection)
              ConfigurationManager.GetSection(configPath);
        }

        /*This regular expression only accepts a valid email address. */
        [RegexStringValidator(@"[\w._%+-]+@[\w.-]+\.\w{2,4}")]
        /*Here, we register our configuration property with an attribute. 
        Note that the default value is required if we use 
        the property validation attributes, which will unfortunately 
        attempt to validate the initial blank value if a default isn't found*/
        [ConfigurationProperty("emailAddress", DefaultValue = "Address@Domain.com")]
        public string EmailAddress
        {
            get { return (string)this["emailAddress"]; }
            set { this["emailAddress"] = value; }
        }
    }
}

In app.config for the library I include next nodes:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <sectionGroup name="cSharpConsultant">
      <section name="notifications"
          type="ClassLibrary1.NotificationsConfigurationSection,
        ClassLibrary1"/>
    </sectionGroup>
  </configSections>
  <cSharpConsultant>
    <notifications emailAddress="NotifiedPerson@Domain.com"/>
  </cSharpConsultant>
</configuration>

Could anybody help me?

  • 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-17T19:15:27+00:00Added an answer on May 17, 2026 at 7:15 pm

    Do you mean that your app.config was in the project for the library?

    The configuration files must be in the same project as your executable. The definition for the custom section can remain in the library, but the configuration file itself must be in the same project as the one you are intending to run.

    In your case, it should be in the same project as ConsoleApplication1 rather than ClassLibrary1

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

Sidebar

Related Questions

I have a script that I want to exit early under some condition: if
My ASP.NET web application works fine in Internet Explorer, but in Firefox and Chrome
I am working though some simple DX tutorials, and have hit an early snag.
Soo, I think this might be early, but I have a need for usb
So, being an early adopter, I have developed an application based on SQLCE4, ASP.Net
I'm designing a site. It is in a very early stage, and I have
I'm early on in my PowerShell learning, and I'm wondering if there are some
I am in early beginning of learning and deploying Win App using C#, Now
I'm working on early designs for an application that needs to start out small
I have a UIViewController whose view has a custom subview. This custom subview needs

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.