Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to programatically set a single endpoint for a WCF service
    primarykey
    data
    text
    <p>I'm trying to allow for user configuration of a WCF service, including the IP and port number that the service listens on. The user has a separate config application that allows for these values to be set, but the problem I am running into is that the app.config MUST have an endpoint defined in order to create a new ServiceHost entry...but my endpoint is being defined in a separate configuration file and must then be bound programatically at runtime. </p> <p>If I do the following (based on <a href="https://stackoverflow.com/questions/966323/how-to-programatically-modify-wcf-app-config-endpoint-address-setting">How to programatically modify WCF app.config endpoint address setting?</a>:</p> <pre><code> m_SvcHost = new ServiceHost(this); if (Config.ServiceEndpoint != null &amp;&amp; Config.ServiceEndpoint != String.Empty) { m_SvcHost.AddServiceEndpoint(typeof(IMyService), new BasicHttpBinding(), Config.ServiceEndpoint); } m_SvcHost.Open(); </code></pre> <p>the service will listen on BOTH the URI defined in the app.config, AND the URI defined in the configuration file. There is no way that I can find to remove the original endpoint or to create the service without an endpoint defined.</p> <p>Writing to the app.config from the configuration application is not an option - I need to pull the configured value programatically from the separate XML config file....</p> <p>any thoughts?</p> <p>EDIT: the service runs as a Windows Service and exposes an HTTP endpoint, it is not running as a web service hosted in IIS - if that changes things at all</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.
 

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