Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Dear all,

I have an application (VB.Net 2.0) with a client and a remoteing server.
Once the clients starts his work, he registers with the server and receives a session-ID. The session data is stored on the server and the client receives the session id.
Once registered, the client stores the session id in the CallContext using "SetData()".

Everything works fine until the session id gets lost (e.g. due to a server restart).
The client checks for a valid session id and if his id is not valid, he requests a new id. so far: everything fine.

Now the client updates CallContext with the new session id, but this step does only work for the client. the server still receives the old ID when called and runs in errors as he considers the client "not registered".

I tried
- CallContext.GetData/SetData
- CallContext.LogicalGetData/SetData
- trying to delete the old data with CallContext.FreeNamedDataslot.
without success.

Edit:
Here is the piece of code on the client side.
I have translated the comments
VB
''' <summary>
  ''' Register client at session manager (on the RemotingServer)
  ''' </summary>
  Public Shared Sub RegisterClient()
    ' Singleton
    Dim obCC As ClientContext = ClientContext.GetInstance
    Dim cltToken As ClientToken ' Implements ILogicalThreadAffinative
    Try

      Trace.WriteLineIf(m_TraceSwitch.Enabled, ">> Register Client")
      Trace.Indent()

      ' shows the step in the init screen.
      InitialisierungsBildschirm.SetzeSchritt("Client registrieren.")

      ' initialize the process
      obCC.InitializeClient(AktuellerBenutzer.UserLoginName, My.Computer.Name)

      obCC.RegisterClientAtSessionManager()  ' Remote call

      'CallContext.SetData("ClientId", obCC.GetClientToken) this is old version
      CallContext.LogicalSetData("ClientId", obCC.GetClientToken)

    Catch ex As Exception
     ' internal exception handling, then:
      Throw

    Finally
      Trace.Unindent()
      Trace.WriteLineIf(m_TraceSwitch.Enabled, "<< Register Client")

    End Try

  End Sub


And this shows how the server tries to retrieve the context setting:

VB
''' <summary>
''' Get the Clientsettings
''' </summary>
''' <returns>ClientSettings object</returns>
Public Function GetClientSettings() As ClientSettings

  Dim m_SessionManager As ISessionManager
  Dim m_ClientToken As ClientToken

  'get CallContext (ClientID).
  'm_ClientToken = CType(CallContext.GetData("ClientId"), ClientToken) this is old version
  m_ClientToken = CType(CallContext.LogicalGetData("ClientId"), ClientToken)

  'CallContext (ClientId) not available
  If m_ClientToken Is Nothing Then
    Return Nothing
  End If

  'ClientId avaiblable: Remoting 'SessionManager'.
  If m_ClientToken.ClientID <> String.Empty Then
    Try
      ' create access path to session manager
      m_SessionManager = GetSessionManager()
    Catch
      Throw
    End Try

    'Return ClientSettins
    Return m_SessionManager.GetClientSettings(m_ClientToken.ClientID)
  Else
    Return Nothing
  End If
End Function


I deleted some exception handling.
No exceptions occur during runtime on either side.

Any idea how to solve this problem would be greatly appreciated.

Thomas
Posted
Updated 5-Jun-12 20:19pm
v3
Comments
Shahin Khorshidnia 5-Jun-12 13:24pm    
Without code, I can't help so much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900