How do I use the windows service and WCF to update some record in database? -
i wrote wcf service , host wcf in windows service using tcp.and using command installutil windowsservicesendmail.exe register on windows 7.
my problem service not start when right click on service1(on window services on windows 7) , click start. read article , went forward step step result did not receive.
this runprogram() method in wcf project in solution
[operationcontract] void runprogram(); public void runprogram() { //code check database }
this code in windows service project in solution
protected override void onstart(string[] args) { if (myservicehost != null) { myservicehost.close(); } myservicehost = new servicehost(typeof(service1)); myservicehost.open(); } protected override void onstop() { if (myservicehost != null) { myservicehost.close(); myservicehost = null; } }
and add reference wcf project windows service project
and using command installutil windowsservicesendmail.exe register on windows 7
you can download project here
my problem service not start when right click on service1(on window services on windows 7) , click start.
i've found problem. changed onstart method.
protected override void onstart(string[] args) { if (myservicehost != null) { myservicehost.close(); } myservicehost = new servicehost(typeof(sendmailservice)); myservicehost.open(); wcfsendmail.sendmailservicewcf s = new wcfsendmail.sendmailservicewcf(); s.runprogram(); }
and publish windows service project , run setup.exe in publish folder. of course using command installutil windowsservicesendmail.exe register on windows 7.
Comments
Post a Comment