我正在尝试创建一个简单的程序,它将id作为int发送,并根据id获取数据。但我不断收到这个错误。
Cannot load type 'remote.RemoteObjectClass, remoteclient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
服务器
TcpServerChannel channel = new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Class1), "1",
WellKnownObjectMode.Singleton);
label1.Text = "started";
客户端
RemoteObjectClass obj1 = (RemoteObjectClass)Activator.GetObject(
typeof(RemoteObjectClass),
"tcp://localhost:8086/1");
if (obj1 == null)
{
label1.Text = "Could not locate TCP server";
}
Class1 cl = obj1.kk(Convert.ToInt32(textBox1.Text)); -- **got error here**
RemoteObjectClass
class RemoteObjectClass : System.MarshalByRefObject
{
public int c(int i)
{
return 33;
}
public Class1 kk(int i)
{
Class1 k = new Class1();
return k;
}
ClassLibrary
namespace ClassLibrary1
{
public class Class1 : System.MarshalByRefObject
{
public string ad;
public int id;
}
}
答案 0 :(得分:5)
如果Caller和Called RemoteObject Classes位于不同的名称空间中,则可能会发生此错误。