Welcome

首页 / 软件开发 / C# / Remoting方法重载遇到的一个问题

Remoting方法重载遇到的一个问题2010-07-27 博客园 zhuweisky在通过Remoting调用重载的泛型方法时,遇到了一个奇怪的问题,现使用一个例子一步步来说明如下。

一.没有重载的情况

假设Remoting的接口是IComputer:

public interface IComputer
{
int Add<TEntity>(TEntity c);
}
在Remoting Server上的实现非常简单:

public class Computer : IComputer
{
public int Add<TEntity>(TEntity c)
{
return 0;
}
}
然后,通过Spring.net分别在配置Server和Client的Remoting通道,接着Client作如下调用:

IComputer remoteComupter = (IComputer)Program.SpringContext.GetObject("remotingComputer");
int res2 = remoteComupter.Add<GameRecordDetail>(new GameRecordDetail());
这个调用是成功的,没有任何问题,返回值为0。