I have a service that looks like this:
[ServiceContract(SessionMode = SessionMode.Required)]
public interface ILabListener
{
[OperationContract]
byte[] GetChallenge();
...
...
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerSession)]
class LabListener : ILabListener
{
private byte[] challenge;
public LabListener()
{
[challenge is initialized to random data from RNG]
File.AppendAllText(Program.LogPath, String.Format("{1} - Starting LabListener session: {2}, challenge: {3}{0}",
Environment.NewLine, DateTime.Now, OperationContext.Current.SessionId, Convert.ToBase64String(auth.Challenge.Take(16).ToArray())));
}
public byte[] GetChallenge()
{
return challenge;
}
...
...
var binding = new NetTcpBinding(SecurityMode.None);
host = new ServiceHost(typeof(LabListener), new Uri(String.Format("net.tcp://{0}:800/LabListener", Environment.MachineName)));
host.AddServiceEndpoint(typeof(ILabListener), binding, "");
...
LabListenerClient client = new LabListenerClient();
Console.WriteLine(Convert.ToBase64String(client.GetChallenge());
Console.WriteLine(Convert.ToBase64String(client.GetChallenge());
When hosting this service in MS .net on Windows, the output of each GetChallenge is the same and the constructor for LabListener is only called once.
If I host this in mono 2.6.7 under OpenSuSE 11.3, a new LabListener is created for each call to GetChallenge, and two different values are returned.
this is the log output on the server on Linux:
8/26/2010 8:07:57 PM - Starting LabListener session: urn:uuid:5e41d193-c723-4839-abc0-93103dbd63f1, challenge: hDPwoofYUrEjAJ1Q8cWDYw==
8/26/2010 8:07:57 PM - Starting LabListener session: urn:uuid:5e41d193-c723-4839-abc0-93103dbd63f1, challenge: 6/3M4EhiKrAMM2j47MCIpQ==
How do I correct the mono behavior?