0

I have a WCF service that sits in front of an ASMX web service. This ASMX service is my data access mechanism for a remote system. I am creating this connection as a singleton as the first call takes about 10 seconds, while subsequent calls take about one second.

Currently, I am testing the service with a console test host using netTcpBinding. When in production, we will host it inside IIS using the wsHttpBinding.

My expectation would be that to have a persistent singleton in my data access layer I would have to set my InstanceContextMode to Single. So far however, I have not seen any timing differences no matter what I set the InstanceContextMode to (PerCall, PerSession or Single). I can't be certain that my testing reflects reality though.

So my question is will my InstanceContextMode affect the creation of this singleton object? If so, how?

1 Answer 1

1

Short Answer: No, it will not affect it.

Longer Answer: If you are creating your singleton using a static variable in the class for the ASMX connection, then the instance will only exist once per AppDomain, no matter what. This means that your WCF InstanceContextMode will not affect the calls to the Singleton, since each instance of the WCF Service will only get the single instance from the static variable.

1
  • Thanks Ryan. It seems that WCF InstanceContextMode is not related to instantiation within an AppDomain.
    – Mike
    Dec 10, 2013 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.