远程对象: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文件中确实没有生成这个文件,不懂是哪出了问题。
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文件中确实没有生成这个文件,不懂是哪出了问题。
<channels>
<channel ref="tcp" port="9999"/>
</channelS>
我改过了,不是不行。