I've been following Miguel Castro's excellent article on WCF here and it's all working nicely, except that I have the following code
public AdminClient()
{
ChannelFactory<IProductAdmin> factory = new ChannelFactory<IProductAdmin>();
productAdminChannel = factory.CreateChannel();
}
In my app.config file, I have the following configuration:
<system.serviceModel>
<client>
<endpoint address="net.tcp://localhost:8002/ProductBrowser"
binding="netTcpBinding"
contract="Contracts.IProductAdmin" />
</client>
</system.serviceModel>
But, when I run the constructor for AdminClient I get an exception saying that the endpoint isn't defined. However, if I change my configuration to give the endpoint a name, and then create the factory as follows, it works.
public AdminClient()
{
var fac = new ChannelFactory<IProductAdmin>("admin");
productAdminChannel = fac.CreateChannel();
}
<system.serviceModel>
<client>
<endpoint name="admin"
address="net.tcp://localhost:8002/ProductBrowser"
binding="netTcpBinding"
contract="Contracts.IProductAdmin" />
</client>
</system.serviceModel>
I'd love an explanation for this. The documentation in MSDN isn't much help...