Click here to Skip to main content
15,745,509 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new to this topic and can't seem to figure this out. So in my wcf service project I wrote what is intended to be a constantly running service that continually reads data from a database and processes it. Using the VS self host environment, it works great.

So now I want to host this in a windows service. Created the service and set references to my wcf service. Code looks like this:

private ServiceHost _host;
        private LabService ls = new LabService();

        public LabParserWindowsService()

        protected override void OnStart(string[] args)

            _host = new ServiceHost(typeof(LabParserService.LabService));

        protected override void OnStop()

Install the service and start it. Nothing happens. It starts ok but the wcf service isn't doing anything. The StartProcess() method in the wcfservice is what should kick things off but it never fires (I'm logging to db to see when it starts). Most examples I see do not have anything other than the _host.Open() part.

So how, from this windows service, do I actually start my wcf service running (invoke StartProcess)?

ZurdoDev 11-Dec-13 16:27pm    
I would assume you can just add a reference to the wcf project, make sure your class is public, and just call the method you want. The problem is WCF is meant for things like Web Services, essentially sitting there waiting for someone to call them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900