App.config in Windows Service C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TechBabu
    New Member
    • Sep 2010
    • 2

    App.config in Windows Service C#

    I'm trying to read data from config file in windows service in OnStart(), but it is throwing error "Object reference not set to an instance of an object".
    Is there any seeting required to use config file in Windows Service.
    my config file name as <appName>.exe.c onfig.
    Even I placed it in the System32 folder also.
    Plz help me out how to handle config file in Windows Service.
    I'm using VS2008, C#.

    Thanks in advance.
  • Sfreak
    New Member
    • Mar 2010
    • 64

    #2
    TechBabu,

    You dont need to specify directly the app.config file. Just include it (Add-->New Item-->Application Configuration File) and add the reference of System.Configur ation DLL. Use the Keys/Tags you´ve created anywhere in your application. You dont even need to copy this file to system32folder or anywhere else.


    Fernando Mello

    Comment

    Working...