-3

Situation:

I have a solution with 3 projects:

  • Project 1: Type WCF Service
  • Project 2: Type Console application (hosts project 1)
  • Project 3: Type Console application (calls methods of the WCF service, has a service reference to project 1)

Right now for debugging I run project 2 executable as Administrator, this opens the service. Then I run project 3 executable to call methods of the WCF service.

Question 1: I would like to install the service as a Windows Service so that it is always available, meaning when I want to test/use methods of the service I can. How do I instlal the WCF service as a windows service?

Question 2: Currently the WCF service has Console.WriteLine statements to display results of method calls. Because this service is hosted in project 2 the Console.WriteLines write stuff to Project 2 executable. What will happen to those WriteLines when the WCF service is inside a windows service?

Question 3: The WCF service gets config values from app.config using System.Configuration.ConfigurationManager.AppSettings - will the windows service still have access to the app.config? If so how does it resolve where/which app.config to use?

Question 4: How do I debug a WCF service which is hosted in a windows service?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
andrewb
  • 2,995
  • 7
  • 54
  • 95

1 Answers1

1
  1. You don't install WCF services as Windows services directly. You'll either need to host the service in a web server (like IIS) or install your Service Host (Project 2) as a service.
  2. The output will simply be discarded (see this related question). If you need to retain the output then implement a log library like log4net or NLog.
  3. The Windows Service will still have access to the app.config and it follows the same config location semantics as a console application. See this related question for more information about where the config lives.
  4. To debug a Windows Service, you can use the "Attach to Process" feature built into Visual Studio. See the MSDN page for more information.
Community
  • 1
  • 1
M.Babcock
  • 18,753
  • 6
  • 54
  • 84