Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know if this exactly will get you what you are looking for, but I this is what I use to add my WCF endpoints to my Windows Service. This is the code that the service runs to load all the wcf services:</p> <pre><code>IDictionary&lt;string, ServiceHost&gt; hosts; NetTcpBinding binding; CustomBinding mexBinding; private void AddService(Type serviceImp, Type serviceDef, string serviceName) { ServiceHost host = new ServiceHost(serviceImp); string address = String.Format(baseAddress, wcfPort, serviceName); string endAdd = address; string mexAdd = address + "/mex"; ServiceMetadataBehavior behavior = new ServiceMetadataBehavior(); host.Description.Behaviors.Add(behavior); host.AddServiceEndpoint(serviceDef, binding, endAdd); host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, mexAdd); host.Open(); hosts.Add(serviceDef.Name, host); } </code></pre> <p>There's a <code>baseAddress</code> string that I didn't copy in, but it just has the net.tcp address for the endpoint. Likewise for the <code>wcfPort</code>. Different baseAddresses and ports are used for debug, testing and production.</p> <p>Just in case it isn't clear, <code>serviceImp</code> is the service implementation and <code>serviceDef</code> is the interface that defines the contract. Hope this helps.</p> <p><strong>EDIT</strong> - Here are some references I used to help me figure all of this stuff out:</p> <p><a href="http://geekswithblogs.net/hinshelm/archive/2007/05/30/Creating-WCF-Service-Host-Programmatically.aspx" rel="nofollow noreferrer">Creating WCF Service Host Programmatically</a> <br> <a href="http://blogs.msdn.com/drnick/archive/2006/08/08/690333.aspx" rel="nofollow noreferrer">Net.Tcp Port Sharing Sample, Part 2</a> <br> <a href="http://msdn.microsoft.com/en-us/magazine/cc163412.aspx" rel="nofollow noreferrer">Service Station: WCF Addressing In Depth</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload