远程对象:using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
namespace RemotingObject
{
    public class MyObject:MarshalByRefObject
    {
        public int Add(int a, int b)
        {
            return a + b;
        }
    }
}服务器:using System.Text;
using System.Runtime.Remoting;
using System.Configuration;
namespace RemotingServer
{
    public class MyServer
    {
        [STAThread]
        static void Main(string[] args)
        {
            RemotingConfiguration.Configure("RemotingServer.exe.Config",false);
            Console.ReadKey();
        }
    }
}服务器的配置文件:<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.runtime.remoting>
    <application>
      <service>
        <wellknown type="RemotingObject.MyObject,RemotingObject" objectUri="RemotingObject.MyObject" mode="Singleton"/>
      </service>
      <channel>
        <channel ref="tcp" port="9999"/>
      </channel>
     </application>
  </system.runtime.remoting>
</configuration>运行时中断在RemotingConfiguration.Configure("RemotingServer.exe.Config",false);
提示无法找到RemotingServer.exe.Config,在bin文件中确实没有生成这个文件,不懂是哪出了问题。

解决方案 »

  1.   

    服务器的配置文件 
    <channels>
            <channel ref="tcp" port="9999"/>
    </channelS>
    我改过了,不是不行。
      

  2.   

    我把配置文件的名字改了原来为App.config,我把它改为了MyServer.config,改回原来的就行了,估计.Net生成配置文件时,直接就是找App.config这个文件,没有的话就无法生成吧。