Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't find main static main method in WCF

Tags:

c#

wcf

I created WCF service and faced with a problem. I need to update database periodically, but i couldn't find static method like Main, that whould do it without client interaction. What can i do??? What wold you suggest in such case?

like image 356
Nate Avatar asked Jun 04 '12 13:06

Nate


1 Answers

There is no Main method (or similar entry point) in WCF. You need to host your WCF service in another process (such as a Windows service, or IIS or self host) to "activate" it and make it available to other processes.

One of the concepts in WCF is that you write your service code to do the function you need without having to worry about infrastructure and hosting. Once you have written your service logic, you can then decorate and configure your service to expose it to other processes. Using this approach means you can change how your service is exposed to other processes without re-writing the actual service logic - you essentially just change your configuration. Hence, a main entry point is specific to how you choose to host and expose your WCF service to the outside world.

Just Google around for "WCF hosting" and you will find lots of information.

If you don't need to expose your service logic to an external process (which sounds like maybe the case from your question) then maybe you don't need to use WCF and you can just write a plain old Windows Service.

like image 157
RobertMS Avatar answered Sep 28 '22 08:09

RobertMS