Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:29:19+00:00 2026-06-17T11:29:19+00:00

I have a WCF service which connect to multiple clients. The service is configured

  • 0

I have a WCF service which connect to multiple clients.
The service is configured as follows:

ServiceBehavior(
        InstanceContextMode = InstanceContextMode.Single,
        UseSynchronizationContext = false,
        ...

in the service I use identify clients using OperationContext.Current.SessionId.

public void Register()
{
        Debug.WriteLine(OperationContext.Current.SessionId);
}

Imagine the following scenario:
– Client1 calls Register
– The service runs Register in Thread1
– After a certain time Client2 calls Register
– The service runs Register also in Thread1 (which is theoretically possible, no?)

Knowing that OperationContext.Current is ThreadStatic,
What’s display the second call :

  • Session 1 because OperationContext.Current is already set in the first call
  • Or Session 2 ..?

Thank you in advance …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:29:20+00:00Added an answer on June 17, 2026 at 11:29 am

    You will get Session2. Session and Instantiation are 2 different things in WCF. I would recommend you read the following 2 blog entries that will help you understand the concepts of WCF sessions and instantiation.

    http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,af6e6325-2e30-42e3-acb9-57e1363fa51e.aspx

    http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,1efac821-2b89-47bb-9d27-48f0d6347914.aspx

    you can also test this with a client. I changed your WCF method to return the sessionID and consumed it in the client.

    static void Main(string[] args)
    {
          ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
          Console.WriteLine(client.Regster());
          Console.ReadLine();
          client.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've have a WCF service which has multiple clients that it connects to. What
I have a wcf service which use wsDualHttpBinding, i get that error when i
I have a WCF-Service with custom ServiceCredentials implemented, they use a custom ServiceCredentialsSecurityTokenManager which
I have a WCF service that all clients connect to in order to get
I have a WCF web service which allows both Basic HTTP and WS-HTTP clients,
I have a remote wcf service, I connect it by WSHttpBinding. If I use
I have a WCF service which accepts a string as a paramter for one
I have a WCF service which works on my dev machine running IIS 7,
I have a WCF service which performs CRUD operation on my data model: Add,
I have a WCF service which references a 3rd party DLL. That DLL looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.