How to create client proxy without svcutil or add service reference in wcf?

wcf

Solution

If you have access to the service contract (the IService interface) in a separate DLL, you can add a reference to that service contract DLL and then do something like:

NetTcpBinding binding = new NetTcpBinding();
EndpointAddress address = new EndpointAddress("net.tcp://localhost:9000/YourService")

ChannelFactory<IService> factory = new ChannelFactory<IService>(binding, address);
IService proxy = factory.CreateChannel();

and then you have your programmatically created proxy, which you can now use as you wish.

Problem

How can I create a client proxy without svcutil.exe or add service reference in wcf? I want to create a client proxy at compile time.

Original source