WCF Base Address Doesn’t Match Scheme for Non-HTTP Binding
While working on the Seed Core Processor code I came across this exception in my WCF code.
An unhandled exception of type ‘System.InvalidOperationException’ occurred in System.ServiceModel.dll
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
…
Could not find a base address that matches scheme net.pipe for the endpoint with binding NetNamedPipeBinding. Registered base address schemes are [http].
Given that my code was copied almost directly out of Microsoft’s very helpful Getting Started Tutorial I was a little confused.
Uri BaseAddress = new Uri("net.tcp://localhost/test");// Step 1 of the hosting procedure: Create ServiceHost
ServiceHost SelfHost = new ServiceHost(typeof(SensorServiceProvider), BaseAddress);
try
{
// Step 3 of the hosting procedure: Add a service endpoint(s).////Named pipe endpoint
SelfHost.AddServiceEndpoint(
typeof(SensorServiceContract),
new NetNamedPipeBinding(),
"pipe");//TCP endpoint
SelfHost.AddServiceEndpoint(
typeof(SensorServiceContract),
new NetTcpBinding(),
"tcp");// Step 4 of the hosting procedure: Enable metadata exchange.
ServiceMetadataBehavior mex = new ServiceMetadataBehavior();
mex.HttpGetEnabled = true;
SelfHost.Description.Behaviors.Add(mex);// Step 5 of the hosting procedure: Start the service.
SelfHost.Open();
}
A good half-hour of Googling turned up a variety of possible causes for this exception, none of which turned out to be my problem. I finally found some sample code that revealed the issue, if you haven’t noticed already. The base address is using http, but neither the named pipes or tcp endpoints use this protocol. Changing “http” to “net.pipe” or “net.tcp” will enable the named pipes or tcp endpoints, respectively. And so it would appear I need multiple ServiceHost objects to enable named pipe and tcp access to my service concurrently. (Which will require a singleton and more documentation reading.)
Simple enough, but I’m just starting and it’s easy to miss stuff like this, so I though I’d share and hopefully save the next beginner some head scratching time.
This entry was posted on Saturday, August 9th, 2008 at 3:39 pm and is filed under Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

