none
WCF Contract Instance RRS feed

  • Question

  • Hi

    In my windows service, I am creating instance of a WCF Service contract within the parallel.foreach loop.

    In this how to identify/verify, does it creates a new instance every time within the loop or uses the existing instance. 

    Can we able to find this using the Debugging the code or tracing

    Thanks,

    Abinesh

    Wednesday, May 31, 2017 10:47 PM

All replies

  • >> does it creates a new instance every time within the loop or uses the existing instance.

    What do you mean by this instance? Is it client object or service object? I assume you mean service contract instance. If so, it depends on how you set InstanceContextMode.

    There are three modes.

    PerCall: A new InstanceContext (and therefore service object) is created for each client request.

    PerSession: A new InstanceContext (and therefore service object) is created for each new client session and maintained for the lifetime of that session (this requires a binding that supports sessions).

    Single: A single InstanceContext (and therefore service object) handles all client requests for the lifetime of the application.

    You could refer the link below for more information.

    # Instancing

    https://msdn.microsoft.com/en-us/library/ms731193%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, June 1, 2017 5:42 AM