By combining the answers of gWiz and Dylan, I came up with a way to do this, although I did not check it carefully enough to see if I had violated any other functions with these changes.
Basically, I added this class:
public class MobileMonitoringSvcHost : ServiceHost { protected override void ApplyConfiguration() {
This skips the call to ServiceHost "ApplyConfiguration" and (probably now is not necessary, because if the configuration is not loaded, there should be no endpoints) clears the endpoints. Then I do the following:
m_SvcHost = new MySvcHost(this); if (Config.ServiceEndpoint != null && Config.ServiceEndpoint != String.Empty) { //m_SvcHost.Description.Endpoints.Clear(); m_SvcHost.AddServiceEndpoint(typeof(IMobileMonitoringSvc), new BasicHttpBinding(), Config.ServiceEndpoint); } // open the svchost and allow incoming connections m_SvcHost.Open();
This causes the service to only listen on the external custom endpoint, not the app.config custom endpoint
Thanks!
source share