我写了windows服务程序做为服务端
protected override void OnStart(string[] args)
{
  th = new Thread(new ThreadStart(ServiceThread));
  th.Start();
//RemotingConfiguration.Configure("SimpleServer.exe.config");
}
void ServiceThread()
{
   RemotingConfiguration.Configure("SimpleServer.exe.config");
}
客户端没法正常运行。
如果服务端写成控制台程序
static void Main(string[] args)
{
         RemotingConfiguration.Configure("SimpleServer.exe.config");         Console.WriteLine("Press return to exit");
         Console.ReadLine();
}
客户端就正常。
请问什么原因???

解决方案 »

  1.   

    SimpleServer.exe.config配置文件是
    <configuration>
    <system.runtime.remoting>
    <application name="SimpleServer">
    <service>
    <wellknown mode="SingleCall" type="Wrox.Samples.MyRemoteObject, MyRemoteObject" objectUri="MyRemoteObject" />
    </service>
    <channels>
    <channel ref="tcp server" port="9000" />
    </channels>
    </application>
    </system.runtime.remoting>
    </configuration>
    remoting程序的代码为:
    using System;namespace Wrox.Samples
    {
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    public class MyRemoteObject : System.MarshalByRefObject
    {
    public MyRemoteObject()
    {
                         Console.WriteLine("Constructor called");
    }                  public string Hello()
                      {
                         Console.WriteLine("Hello called");
                         return "Hello, .NET Client!";
                      }
    }
    }
      

  2.   

    看看
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT15.asp