I'm comparing two examples of WCF.
Microsoft's examples http://msdn.microsoft.com/en-us/library/ms734712.aspx uses app.config file, uses generator svcutil.exe
to generate client and in general produces much more code.
Another example http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication much simpler - only two C# files, no auto generated code, no app.config.
Both examples seems to do the same thing.
The question is:
- should I use app.config in my program or this file is redundant?
- should I tr开发者_JS百科y to use Microsoft's "auto-generate client" program or it's better to avoid it?
- which of these two examples I should follow when implementing own WCF program?
WCF allows you to configure the bindings either programmatically or via configuration. Configuration is sometimes convenient if you (or someone else like a test team/customer) trying out different binding options. For example, the QA team could be doing perf testing and trying the different ways to serialize data over the wire. Or, a customer may have different firewall constraints etc...
In both cases, being able to change binding options on the fly without recompiling is useful.
If you know exactly how you want to send the data, then programmatically configuring it and compiling it into your code may be best. It's certainly easier to configure and less error prone.
精彩评论