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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:05:54+00:00 2026-05-28T05:05:54+00:00

I’m trying to pull some key/values in my class. This is a C# Class

  • 0

I’m trying to pull some key/values in my class. This is a C# Class Library Project (not web project) so it’s got an App.Config.

In my C# Project (Class Library), got the following:

1) A utility method to pull a key/value from a config file:

public class ConfigUtil
{
    /// <summary>
    ///  Utility method to retrieve configuration setting values.
    /// </summary>
    /// <param name="configKey">Configuration Settings key to retrieve.</param>
    /// <returns>empty string if key is null</returns>
    public static string GetAppConfigSetting(string configKey)
    {
        return ConfigurationManager.AppSettings[configKey] ?? string.Empty;
    }
}

This utility method was used in a web project and I just copied and pasted this nice helper into my C# Project because I need these auth and end points for authing to a third party API in some code in my C# Project.

2) A Config.cs to hold my lookups

class Config
{
    public static string SomeThirdPartyApiEndpoint
    {
        get { return ConfigUtil.GetAppConfigSetting("SomeThirdPartyApiEndpoint"); }
    }

    public static string SomeThirdPartyApiAuthUsername
    {
        get { return ConfigUtil.GetAppConfigSetting("SomeThirdPartyApiAuthUsername"); }
    }

    public static string SomeThirdPartyApiAuthPassword
    {
        get { return ConfigUtil.GetAppConfigSetting("SomeThirdPartyApiAuthPassword"); }
    }
}

3) In my App.Config, the key/values:

  <appSettings>
    <add key="SomeThirdPartyApiEndPoint" value="http://someEndPointUrl.com/XMLAPI" />
    <add key="SomeThirdPartyApiAuthUsername" value="someUserNameHere" />
    <add key="SomeThirdPartyApiAuthPassword" value="5233s54" />
  </appSettings>

4) Some example code in one of my classes in this project trying to pull one of the key values:

string password = Config.SomeThirdPartyApiAuthUsername;

this line is in one of my class methods.

The problem: it’s not finding any of my key/values. When I debug, I get an empty string for password.

I assume I’m doing this right in that these key/values need to be put in my App.Config since I do not have a web.config since this is not a Web Project. This is a wrapper project I am creating to wrap calls to a third party API.

Another question related: So then would then ConfigurationManager.AppSettings look for an App.Config if a Web.config is not present? I am wondering how this ConfigurationManager pulls…does it look for only web.configs or any .config available in the immediate project?

  • 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-28T05:05:54+00:00Added an answer on May 28, 2026 at 5:05 am

    I believe that the ConfigurationManager.AppSettings looks in the configuration file of the running program. If this is a library project, you need to add the settings you want to the config file of the host.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.