WCF tutorial | WCF Instance Management
Instance management refers to the way a service handles a request from a client. Instance management is set of techniques WCF uses to bind client request to service instance, governing which service instance handles which client request. It is necessary because application will differ in their need for scalability, performance, durability, transaction and queued calls.
Basically there are three instance modes in WCF:
Instance mode can be configured using ServiceBehavior attribute. This can be specified at implementing the service contract as shown below.
public interface IMyService
public class MyService:IMyService
public int MyMethod()
Comments on this article
- 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.