WCF Service Host using Console App -


is there way automatically add entries app.config of console application used host wcf service or need make entries manually?

i referring <system.servicemodel> section in app.config file configure wcf service.

additional issues service library project's app.config

i understand concept of .svc files , needed in case want host service using iis. start with, plan self-host service using cosole app. issue facing web.config of service library project. when created service library project, app.config automatically created , service configuration automatically generated. however, had changed class names , see error in app.config <service name="myservicename"> parameter , error on service contract attribute.

what's wrong in following configuration? error service name="contactmgrservice.contactmanager" , contract="contactmgrservice.icontactmgrservice"

<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.servicemodel>     <behaviors>         <servicebehaviors>             <behavior name="">                 <servicemetadata httpgetenabled="true" httpsgetenabled="true" />                 <servicedebug includeexceptiondetailinfaults="false" />             </behavior>         </servicebehaviors>     </behaviors>     <services>         <service name="contactmgrservice.contactmanager">             <endpoint address="" binding="basichttpbinding" contract="contactmgrservice.icontactmgrservice">                 <identity>                     <dns value="localhost" />                 </identity>             </endpoint>             <host>                 <baseaddresses>                     <add baseaddress="http://localhost:8733/design_time_addresses/contactmgrservice/service1/" />                 </baseaddresses>                 </host>             </service>         </services>     </system.servicemodel> </configuration> 

service contract

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.text; using contactmgrservice.datamodel.contact;  namespace contactmgrservice.contact { // note: can use "rename" command on "refactor" menu change interface name "iservice1" in both code , config file together. [servicecontract] public interface icontactmgrservice {     [operationcontract]     ilist<contactdata> getcontactlist(int? value);  }  } 

service implementation class:

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using contactmgrservice.datamodel.contact;  namespace contactmgrservice.contact { public class contactmanager : icontactmgrservice {     contactcontext db = new contactcontext();       public ilist<contactdata> getcontactlist(int? value)     {         iqueryable<contactdata> contacts = db.contacts;          return contacts.tolist();     } } } 

your config file incorrect. when specifying service name , endpoint contract values need specify fully qualified name of type containing service or service definition:

<service name="contactmgrservice.contact.contactmanager"> 

and

<endpoint address=""            binding="basichttpbinding"           contract="contactmgrservice.contact.icontactmgrservice"> 

in response other questions:

is mandatory have project svc files?

it highly unorthodox if not impossible use svc files in console applicaiton. strinctly iis.

is there way automatically add entries app.config

nope have manually.


Comments