Why would one use the ChannelFactory to instantiate a WCF proxy rather than a Service Reference?

后端 未结 3 1970
北荒
北荒 2021-01-05 07:23

There seem to be two ways to instantiate WCF service proxies described here. My question is why would one want to use the ChannelFactory to instantiate a WCF proxy and what

3条回答
  •  轮回少年
    2021-01-05 08:02

    If you are using assembly-sharing (which is, let's face it, hugely convenient if you own both ends of the pipe), then both ends already have a complete version if the interface etc. It seems redundant to run the svcutil tool (at command-prompt or via the IDE) just to get back a wrapper for what we already have. It also works very well when you want to code only to an interface, not to the wrapper class - and use some centralised code to get a channel to a particular interface at a given address. This is actually how I mainly use WCF.

    The "client" approach works well for one-off services, or where it doesn't need to go through any central tooling. It also makes for very simple demos.

提交回复
热议问题