How do I specify a contract's namespace in the XML configuration of a WCF endpoint?

I've got this WCF service contract (heavily simplified, but pay attention to the namespace it's in):

namespace Foo.Services.BarService
{
    [ServiceContract]
    interface BarContract {... }
}

In my app.config (client side), I configure an endpoint for some service:

<endpoint address="..."
          binding="..."
          contract="Foo.Services.BarService.BarContract" />

However, this results in an error saying that no endpoint was found in the client's configuration that supports BarService.BarContract. I can only get rid of this error by changing the contract attribute value to BarService.BarContract (i.e. by removing the namespace).

Why is that? Where could this error come from? Why must I not mention the namespace part of a contract type? Shouldn't that result even more in WCF not finding a matching endpoint?


Reply to the questions in @Ladislav Mrnka's comment below:

Upvotes: 3

Views: 1359

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364399

Creating client by Add Service reference does not recreate namespace structure from service. All created types and contracts are placed into new namespace defined by the name of the service reference. So I guess you named your service reference BarService. Client configuration must follow names of generated contracts.

Upvotes: 3

Related Questions