M
Marek
I am having a problem with Hashtable used in XML web server.
I have a WebMethod where clients get registered and added into hashtable.
Later, I call another web method which has client ID as parameter. I first
thought I was doing something wrong with keys, but now i found out the
Hashtable is empty (Count property returns 0)
Code:
[WebMethod()]
public void RegisterClient(int id)
{
if(!this.clients.ContainsKey(id))
{
this.clients.Add(id, new ClientWrapper(id));
return;
}
throw new Exception("ERROR");
}
[WebMethod()]
public void Log(string message, int clientID)
{
if(this.clients.ContainsKey(clientID))
{
ClientWrapper w = (ClientWrapper)this.clients[clientID];
w.Log(message);
return;
}
else
{
throw new Exception("Client not found while logging: " + clientID + "
Client count is " + this.clients.Count) ; //I see from here that the
Hashtable does not contain that key and Count is zero!!
}
}
I am sure that method RegisterClient is called before method Log is called.
I am not able to debug because VS says symbols were not loaded and Debug
class helps me neither because I am getting errors like "Process can not
access the file because it is used by another process" when trying to use
Debug.WriteLine()
Any help would be greatly appreciated.
I have a WebMethod where clients get registered and added into hashtable.
Later, I call another web method which has client ID as parameter. I first
thought I was doing something wrong with keys, but now i found out the
Hashtable is empty (Count property returns 0)
Code:
[WebMethod()]
public void RegisterClient(int id)
{
if(!this.clients.ContainsKey(id))
{
this.clients.Add(id, new ClientWrapper(id));
return;
}
throw new Exception("ERROR");
}
[WebMethod()]
public void Log(string message, int clientID)
{
if(this.clients.ContainsKey(clientID))
{
ClientWrapper w = (ClientWrapper)this.clients[clientID];
w.Log(message);
return;
}
else
{
throw new Exception("Client not found while logging: " + clientID + "
Client count is " + this.clients.Count) ; //I see from here that the
Hashtable does not contain that key and Count is zero!!
}
}
I am sure that method RegisterClient is called before method Log is called.
I am not able to debug because VS says symbols were not loaded and Debug
class helps me neither because I am getting errors like "Process can not
access the file because it is used by another process" when trying to use
Debug.WriteLine()
Any help would be greatly appreciated.