What's new in WCF 4.5 - Part 1
WCF Configuration Validation
In old version of WCF, configuration files are not validated while building the project. But in WCF 4.5 while compiling the project, validation errors will be displayed as warning message in visual studio.
Task-based Async Support
In WCF4.5, by default Task based async service operations methods are generated while Adding Service Reference. This is done for both synchronous and asynchronous method. This allows the client application to call the service operation using Task based programming model.
In WCF 4.5, if you select the “Generate asynchronous operations” while adding service reference. Old form of async operations methods are created in the proxy class
Fig 1: Add service Reference from WCF 3.5
Fig 2: Add service Reference from WCF 4.5
Fig 3: Service Client proxy generated using WCF 3.5
Fig 4: Service Client proxy generated using WCF 4.5
- Always create the service with Interface->Implementation format, mention the contract in Interface.
- Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
- Change the instance mode to per call as default.
- Always catch exception using try/catch block and throw exception using FaultException < T >.
- Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.