.NET远程对象调用Activator.GetObject很慢,需要几分钟

时间:2015-04-01 19:19:47

标签: c# .net remoteobject

.NET远程对象调用Activator.GetObject很慢,需要几分钟。

//Server side
public void Conn (int nPort)
{
  IDictionary Prop = new Hashtable();
  Prop["port"]     = nPort;

  BinaryServerFormatterSinkProvider Server = new BinaryServerFormatterSinkProvider();
  BinaryClientFormatterSinkProvider Client = new BinaryClientFormatterSinkProvider();

  HttpChannel Channel = new HttpChannel(Prop,Client,Server);
  try
  {
    ChannelServices.RegisterChannel(Channel);
  }
  catch
  {
  }
  RemotingServices.Marshal(this,"S1");
}

// Client side
public S1Client(int nTimeout)
{
  IDictionary Prop = new Hashtable();
  Prop["timeout"]  = nTimeout;
  Prop["name"]     = "S1";

  BinaryServerFormatterSinkProvider Server = new BinaryServerFormatterSinkProvider();
  BinaryClientFormatterSinkProvider Client = new BinaryClientFormatterSinkProvider();
  HttpChannel channel = new HttpChannel(Prop,Client,Server);
  ChannelServices.RegisterChannel(channel);
}
public void Conn ()
{
  m_IS1 = (IS1)Activator.GetObject(typeof (IS1), m_strUrl + "/S1");
}

为什么呼叫这么慢,我该怎么办才能让它更快?

可能是导致问题的网络设置,如果是,如何解决问题?

0 个答案:

没有答案