.net - When hosting a WCF REST service in a console app, error finding contract name -
i have wcf rest service works windows service (.net 3.5). make easier build , debug, run console. when this, setting endpoints in console app. when create endpoint, fails error: "the contract name 'irestservice' not found in list of contracts implemented service 'system.runtimetype'."
my interface have [servicecontract] attached it:
namespace restservicelibrary {     [servicecontract]     public interface irestservice     ...   here console app:
namespace restserviceconsole {     class program     {         static void main(string[] args)         {              webservicehost2 webhost = new webservicehost2(typeof(restservice), new uri("http://localhost:8082"));             serviceendpoint ep = webhost.addserviceendpoint(typeof(irestservice), new webhttpbinding(), "");             servicedebugbehavior stp = webhost.description.behaviors.find<servicedebugbehavior>();             stp.httphelppageenabled = false;             webhost.open();             console.writeline("service , running");             console.writeline("press enter quit ");             console.readline();             webhost.close();          }     } }   why getting error? how can fix it?
instead of line,
webservicehost2 webhost = new webservicehost2(typeof(restservice), new uri("http://localhost:8082"));   it should be
webservicehost2 webhost = new webservicehost2(typeof(restservice), true, new uri("http://localhost:8082"));   there 2 constructors webservicehost2, calling 1 expecting service instance. that's why looking contract in system.runtimetype.
Comments
Post a Comment