我有一个看起来像这样的服务:
[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());
在Windows上的MS .net中托管此服务时,每个GetChallenge的输出都是相同的,并且LabListener的构造函数只调用一次。
如果我在OpenSuSE 11.3下的单声道2.6.7中托管它,则会为每次调用GetChallenge创建一个新的LabListener,并返回两个不同的值。
这是Linux上服务器上的日志输出:
8/26/2010 8:07:57 PM - 启动LabListener会话:urn:uuid:5e41d193-c723-4839-abc0-93103dbd63f1,challenge:hDPwoofYUrEjAJ1Q8cWDYw ==
8/26/2010 8:07:57 PM - 开始 LabListener会话: 金塔:UUID:5e41d193-c723-4839-abc0-93103dbd63f1, 挑战:6 / 3M4EhiKrAMM2j47MCIpQ ==
如何纠正单声道行为?
答案 0 :(得分:2)