none
Name ConfigurationManager is not declared RRS feed

  • Question

  •  

    I grabbed some code from the internet to use as a base to write out a log file. When I pasted it into my project in VB.net 2003, I immediately got an error message stating:

    Name ConfigurationManager is not declared

    The code editor is complaining about these two statements:

    Dim folderName As String = ConfigurationManager.AppSettings("").ToString()

    Dim fileName As String = ConfigurationManager.AppSettings("").ToString()

    I've spent a couple of hours surfing the Internet and found that I needed to add the imports statement into my program:

    Imports
    System.Configuration

    I also see lots of threads stating I need to reference system.configuration.dll

    This is glossed over as an easy thing, but when I try to create the reference by right clicking references and selecting add reference, then going to .net, the system.configuration.dll does not show up in the list. I then did a search for the dll on my system and found it in this location: 

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.configuration.dll

    I then tried to register this DLL using "regsvr32 system.configuration.dll", but I get this error:
    ----
    System.configuration.dll was loaded, but the DLLRegisterServer entrypoint was not found.

    This file can not be registered.
    ----

    I also attempted to browse for the file using the add reference utility and it gave me an error stating that a reference to the file could not be added. "This is not a valid assembly or COM component."

    I'm really stuck at this point, I can't reinstall .net framework v2.0, the system won't let me. I can't create a reference and I can't get my program to work.

    Any help will be greatly appreciated.

    Friday, November 13, 2009 12:41 AM

Answers

  • Just a quick note - If "registering the component" was needed, it's not the same process as COM.  You'd need to strongly name the assembly and use gacutil.

    Luckily you don't have to worry about this for what you're after.  Right click your project, select "Add Reference...," choose the ".Net" tab and find/add System.Configuration from the list.
    • Proposed as answer by Cor Ligthert Friday, November 13, 2009 11:39 AM
    • Marked as answer by Jeff Shan Wednesday, November 18, 2009 2:32 AM
    Friday, November 13, 2009 1:24 AM
  • Double click on ConfigurationManager so that it is selected.  Press F1.  Select the ConfigurationManager class link at the top of the page that appears and click.  Select the Example link at the top of the page and click.

    Your code should be similar to the code in the example.  You have it right when Intellisense guides you through the definitions and you have no squigglies.
    • Marked as answer by Jeff Shan Wednesday, November 18, 2009 2:32 AM
    Friday, November 13, 2009 3:17 PM

All replies

  • Just a quick note - If "registering the component" was needed, it's not the same process as COM.  You'd need to strongly name the assembly and use gacutil.

    Luckily you don't have to worry about this for what you're after.  Right click your project, select "Add Reference...," choose the ".Net" tab and find/add System.Configuration from the list.
    • Proposed as answer by Cor Ligthert Friday, November 13, 2009 11:39 AM
    • Marked as answer by Jeff Shan Wednesday, November 18, 2009 2:32 AM
    Friday, November 13, 2009 1:24 AM
  • Hi there,

    you'll need to add a reference to System.Configuration first. Right-click the References -node in your SolutionExplorer, navigate to System.Configuration and click OK.



    Cheers,
    Olaf
    Friday, November 13, 2009 8:25 AM
  • Luckily you don't have to worry about this for what you're after.  Right click your project, select "Add Reference...," choose the ".Net" tab and find/add System.Configuration from the list.

    Err, I should've read that posting to the end, I guess. So never mind my answer, jj - I simply overlooked that syntaxeater already provided the answer. :-)



    Cheers,
    Olaf
    Friday, November 13, 2009 12:40 PM
  • Double click on ConfigurationManager so that it is selected.  Press F1.  Select the ConfigurationManager class link at the top of the page that appears and click.  Select the Example link at the top of the page and click.

    Your code should be similar to the code in the example.  You have it right when Intellisense guides you through the definitions and you have no squigglies.
    • Marked as answer by Jeff Shan Wednesday, November 18, 2009 2:32 AM
    Friday, November 13, 2009 3:17 PM