Im currently developing a system that can load up plugins that are created for it and would like for them to dynamically create a WCF endpoint.
What I am after is this,
Lets look at an example of what im tyring to do. In my testing I have a site with a base address
http://localhost:9812/
What I am trying to do is when I load my plugin, add its WCF endpoint configuration to that url, so ending up with
http://localhost:9812/MyPlugin
I do not want to do this in the web.Config file but rather in code. I have managed to get it to work as long as I change the port number it binds to i.e
http://localhost:9787/MyPlugin
This is what my code looks like so far
public void StartWcfServices()
{
IWcfExample endpoint = new EchoEndpoint();
var uri = new Uri(_baseAddress);
string address = _baseAddress + endpoint.GetName();
var serviceHost = new ServiceHost(endpoint, uri);
serviceHost.AddServiceEndpoint(typeof(IWcfExample), new BasicHttpBinding(), address);
serviceHost.Open();
}
Problem being when I start the web site I get an error
HTTP could not register URL http://+:9812/ because TCP port 9812 is being used by another application.
Any help would be greatly appreciated.