用以下方法没有问题:            //使用TCP通道得到远程对象
            //TcpChannel tcpChan = new TcpChannel();
            //ChannelServices.RegisterChannel(tcpChan, false);
            //IBusinessLogicLayer IBL = (IBusinessLogicLayer)Activator.GetObject(
            //        typeof(IBusinessLogicLayer),
            //        "tcp://localhost:8085/BusinessLogic");
            //if (IBL == null)
            //{
            //    System.Console.WriteLine("Could not locate TCP server");
            //    return null;
            //}但用以下方法代替,却不知怎么得到接口对象:            RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
            IBusinessLogicLayer IBL = ?很少玩这个,请各位指教!

解决方案 »

  1.   

    Remoting比较麻烦,不过,代码例子一搜索也很多的。下面的代码值得参考:
    http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
      

  2.   

    找到一个变通的办法:RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
    IBusinessLogicLayer IBL = (IBusinessLogicLayer)Activator.GetObject(typeof(IBusinessLogicLayer), System.Configuration.ConfigurationManager.AppSettings["keyname"]); "tcp://localhost:8085/BusinessLogic"在config中作一个key值:
    <appsettings>
        <add key = "keyname" value= "tcp://localhost:8085/BusinessLogic" />
    </appsettings>