WCF: issue with tcp binding in IISExpress

时间:2017-06-15 09:33:33

标签: wcf iis-express nettcpbinding

I have a wcf project and I'm creating a client to test it. For some reasons, on my local machine I can run the service only within IIS Express from visual studio. After I start the project, I'm trying to connect to the service from a client, but I'm getting an error:

You have tried to create a channel to a service that does not support .Net Framing. It is possible that you are encountering an HTTP endpoint.

I've read this and this but they're discussing about IIS and not IIS Express.

Here is my code from the client:

NetTcpBinding binding = new NetTcpBinding();
EndpointAddress address = new EndpointAddress("net.tcp://localhost:64255/MyService.svc");
ChannelFactory<IMyInterface> channelFactory = new ChannelFactory<IMyInterface>(binding, address);

channelFactory.Open();
IMyInterface _clientProxy = channelFactory.CreateChannel();
((IClientChannel)_clientProxy).Open();

And when I'm calling the method Open, I'm getting the error above...

Please note that the service accepts only net.tcp protocol.

What do I need to change to call this service hosted in IIS Express from my client?

Edit: when I'm running the project from visual Studio, in the browser I'm seeing the url: http://localhost:64255/MyService.svc

1 个答案:

答案 0 :(得分:2)

长话短说:IIS Express不支持非HTTP协议,例如net.tcp。 IIS Express仅支持HTTP和HTTPS作为其协议