1

I have created a Windows Service that reads various paths from the app.config file and works correspondingly.

I also use the 'Visual Studio Installer' as a installer for my Service.

This is my project structure:

enter image description here

However, when I build the Installer, it does generate the .msi and .exe used to install my service, but it doesn't include the config file that it needs to use to fetch the paths it's using:

enter image description here

Normally, the only thing that I use is the .msi file to install and run the Windows Service (it works perfectly using hardcoded paths) but I can't seem to use it in combination with the config-file.

What I tried is to copy the config file from the service project, and paste it in the folder of the second screenshot, but the service doesn't work when I try to install and run it that way.

What am I doing wrong?

EDIT

I tried adding the .config file manually in the installer project:

enter image description here

Without success however

Kahn Kah
  • 1,389
  • 7
  • 24
  • 49
  • check these links, http://stackoverflow.com/questions/26515084/c-sharp-windows-service-is-it-possible-to-use-the-app-config http://stackoverflow.com/questions/14074563/windows-service-app-config-location – Sameer549 Mar 28 '17 at 08:26
  • Check this, maybe you need to add config to projects output https://www.youtube.com/watch?v=cp2aFNtcZfk – daniell89 Mar 28 '17 at 08:26
  • Thanks Daniel, I tried to add the .config file in the project output folder, it actually puts the config file in the files folder but it doesn't use it I think – Kahn Kah Mar 28 '17 at 08:42
  • Can the person who downvoted the question please motivate the reason? – Kahn Kah Mar 28 '17 at 09:11

1 Answers1

2

Nothing.

App.config is a part of the Service project and NOT of the installer.

It will be in the target installation folder of your Service assembly after installing.

Also App.config will be renamed according to the project's assembly name.

Example

Your assembly name is Watcher.Service, your .exe will be, after compiling Watcher.Service.exe and your app.config now will have the name Watcher.Service.exe.config.