c# - Run WCF Service Library when .exe in debug is ran -
c# - Run WCF Service Library when .exe in debug is ran -
when run wpf uses wcf service library through visual studio wcf service host startup @ same time service starting wcf service library, when click on exe wpf in debug folder doesn't startup there anyway create start in code next code have believed work doesn't.
try { host = new servicehost(typeof(service1), new uri("http://" + system.net.dns.gethostname() + ":8733/databasetransferwcfservicelibarymethod/service1/")); host.open(); }catch(addressalreadyinuseexception) { }
i'm trying not utilize service references.
i'm no expert @ this, perhaps you're missing binding. here simplest illustration can create of hosting , consuming wcf service in code (you'll need add together references system, system.runtime.serializaton, , system.servicemodel, otherwise, code complete).
using system; using system.runtime.serialization; using system.servicemodel; namespace consoleapplication1 { class programme { static void main(string[] args) { // create host on single class using ( servicehost host = new servicehost ( typeof(myservice) , new uri("http://localhost:1234/myservice/myservice") ) ){ // single class include multiple interfaces // different services, each must added here host.addserviceendpoint ( typeof(imyservice) , new wshttpbinding(securitymode.none) // each service can have it's own url, if blank utilize // default above , "" ); // open host can consumed host.open(); // consume service (this cuold in executable) using ( channelfactory<imyservice> channel = new channelfactory<imyservice> ( new wshttpbinding(securitymode.none) , "http://localhost:1234/myservice/myservice" ) ){ imyservice myservice = channel.createchannel(); console.writeline(myservice.getvalue()); } // clean host.close(); } } } [servicecontract] public interface imyservice { [operationcontract] int getvalue(); } public class myservice : imyservice { public int getvalue() { homecoming 5; } } }
c# .net wpf wcf
Comments
Post a Comment