Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows service app.config location

I have installed a C# Windows Service on Windows Server 2008. I installed it with InstallUtil. The service reads some data from the app.config file and it is doing it fine. Can you tell me where this file is located after installing the service? I have been looking for hours but can't find it.

like image 227
Mité Avatar asked Dec 28 '12 19:12

Mité


People also ask

Where is app config for Windows service?

Select your Windows service in the list of installed services, right-click and then select Properties. You can also double click on row representing the service. Locate the "Path to executable" value on the Properties dialog box. The value will include any command line parameters.

Where are Windows services stored?

The database server requires a Services file, which contains information about the known services on your network. The Services file is typically located in %windir%\System32\drivers\etc\services. If the file is missing, check with your system administrator before starting the database server installation process.

Where is app config file in Visual Studio 2010?

Right-click on the project, select Add->New Item..., then select "Application Configuration File" from the list of possible items. Show activity on this post. It would be a template in the templates directory of Visual Studio.


2 Answers

You can verify the exact location of the installed Windows Service by following the steps below:

  1. Bring up the list of Windows Services by clicking the "Services" icon under the "Administrative Tools" icon. You can also get this list by typing "View local services" in the Search Menu under the Start Menu.

  2. Select your Windows service in the list of installed services, right-click and then select Properties. You can also double click on row representing the service.

  3. Locate the "Path to executable" value on the Properties dialog box. The value will include any command line parameters.

  4. Open the folder in which the service executable resides.

If the Windows service has been built with .NET Framework, its configuration will be stored in the corresponding .config file, i.e., the name of the executable suffixed by ".config", e.g., if the name of the executable is "XyzService.exe", then the name of the .config file will be "XyzService.exe.config".

A couple of things to note:

  • If you installed the service after building it on the same machine using say, Visual Studio, then Visual Studio would have transformed the App.config file from the project and placed it in the build output folder automatically (and renamed it appropriately using the above naming convention).

  • If your machine is set to hide file extensions in Windows Explorer, you will see 2 files "XyzService" and "XyzService.exe". In this case, the "XyzService.exe" is your config file. If you then switch off the option to hide file extenions in Windows Explorer, you will then begin to see "XyzService.exe" and "XyzService.exe.config".

  • If you cannot find a corresponding .exe.config file, then it is possible that the code within the service is falling back to default values. In this case, you can place a properly named and formatted config file alongside the service executable and then restart the service and everything should be fine.

like image 123
Umar Farooq Khawaja Avatar answered Oct 02 '22 13:10

Umar Farooq Khawaja


According to Microsoft

For client executables, the application configuration file resides in the same directory as the application's executable and has the same base name as the executable with a .config extension.

Note, if your exe is called appname.exe, and you have Windows explorer set to hide extensions, then your application will display as appname and your config file then it will be displayed as appname.exe (even though the true name is appname.exe.config)

As others have pointed out, InstallUtil doesn't do anything with the config file and it should have copied to the server in the same manner as the exe itself.

like image 34
sgmoore Avatar answered Oct 02 '22 13:10

sgmoore