Remoting 调用远程sington对象的方法抛出异常
程序有三个模块组成,
一个公共模块dll,定义远程对象,及一些参数类
一个客户端exe,调用服务器端的远程sington对象的方法,传递可序列话的参数
一个服务器exe,提供客户端访问的远程sington对象
问题:在客户端调用方法时,服务器抛出异常,异常信息调用堆栈显示,是服务器获取客户端传输的参数时超时,请高手分析什么问题。
测试环境1:客户端在win7系统的电脑A,服务器在xp系统的电脑B,出现以上描述问题
测试环境2:同样的程序,客户端运行在xp,服务器运行在win7时,结果正常。
代码:
///公共模块
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace eocDemoCommon
{
public class ServerImpl : MarshalByRefObject, IServer
{
public bool CallFun(ClientParam para)
{
Console.WriteLine(para.User + para.Pwd);
return true;
}
}
public interface IServer
{
bool CallFun(ClientParam para);
}
[System.SerializableAttribute()]
public class ClientParam : MarshalByRefObject
{
private string _user;
private string _pwd;
public string User{
get { return _user; }
set { _user = value; }
}
public string Pwd
{
get { return _pwd; }
set { _pwd = value; }
}
}
}
///客户端
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting;
using eocDemoCommon;
namespace eocDemoClient
{
class Program
{
static void Main(string[] args)
{
IServer service;
string uri = "";
RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
foreach (WellKnownClientTypeEntry clienttype in RemotingConfiguration.GetRegisteredWellKnownClientTypes())
{
Console.WriteLine(clienttype.ObjectUrl);
uri = clienttype.ObjectUrl;
break;
}
if (uri.Length >= 0)
{
service = (IServer)Activator.GetObject(typeof(IServer), uri);
try
{
ClientParam parm = new ClientParam();
parm.User = "hello ";
parm.Pwd = "world";
service.CallFun(parm);
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadKey();
}
}
}
}
}
///服务器
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting;
namespace eocDemoServer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
try
{
RemotingConfiguration.Configure(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, false);
}
catch (Exception ex)
{