Thread: ConfigurationSettings.GetConfig() always returns null

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    ConfigurationSettings.GetConfig() always returns null

    The following always indicates that the config section is not found
    Code:
    if ((IDictionary)ConfigurationSettings.GetConfig("LogSettings") == null)
    {
        Console.WriteLine("I'm null");
        return;
    }
    else
    {
    
    }
    Here's the whole content of app.config
    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <section name="LogSettings"
                 type="System.Configuration.SingleTagSectionHandler"/>
      </configSections>
    
      <LogSettings EnableLog="True"
                   LogDirPath="Log"
                   LogFileBaseName="Log"
                   ErrorEventLogFileBaseName="Log.Error" 
                   PrefixMessageWithDateTime="True"
                   ExpiryDays="15"
                   DeleteExpiredLogFiles="True" 
                   WriteErrorEventToSeparateFile="True"
                   AppendLogFileNameWithDateTime="True"
                   SendEmailOnErrorEvent="True"
                   EmailTo="[email protected]"
                   EmailFrom="[email protected]"
                   EmailCc="[email protected]"
                   EmailBcc="[email protected]" />
      
    </configuration>
    So, why haven't I been able to read "LogSettings" section? Thanks for the help.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #2
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    I tried it on another computer thinking it was bad installation, but, nope, same thing. At home was VS 2005, .NET 1.1 and 2.0; at work was VS 2003, .NET 1.1.

    Can anyone try it on their computer if the method (ConfigurationSettings.GetConfig) works at all? Thanks. I appreciate it.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    2
    Quote Originally Posted by alphaoide
    I tried it on another computer thinking it was bad installation, but, nope, same thing. At home was VS 2005, .NET 1.1 and 2.0; at work was VS 2003, .NET 1.1.

    Can anyone try it on their computer if the method (ConfigurationSettings.GetConfig) works at all? Thanks. I appreciate it.
    just an ide but have try:

    Code:
    Code:
    
    if (ConfigurationSettings.GetConfig("LogSettings" == null) //<-- with no cast?
    {
        Console.WriteLine("I'm null");
        return;
    }
    else
    {
    
    }
    (((also empty blocks should be documented)))

  4. #4
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    @notsure, same thing, the method returns null.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  5. #5
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    For two days I thought I would hate .NET. I figured out my mistake.

    I have a solution with two projects: a class library and it's driver. The App.config was in class library project, when it's supposed to go in the driver project.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Not Saving Value as Int
    By bar338 in forum C Programming
    Replies: 4
    Last Post: 05-04-2009, 07:53 PM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Help with yacc/compiler design/seg fault
    By trippeer in forum C Programming
    Replies: 1
    Last Post: 04-08-2005, 03:43 AM
  4. Problem with a menu.
    By Rare177 in forum Windows Programming
    Replies: 4
    Last Post: 09-07-2004, 11:51 PM
  5. button 'message'
    By psychopath in forum Windows Programming
    Replies: 12
    Last Post: 04-18-2004, 09:57 AM