无法加载类型错误,.Net远程处理
我正在尝试制作一个简单的程序,它以int的形式发送一个id,并根据id获取数据。但我一直得到这个错误无法加载类型错误,.Net远程处理,.net,remoting,.net,Remoting,我正在尝试制作一个简单的程序,它以int的形式发送一个id,并根据id获取数据。但我一直得到这个错误 Cannot load type 'remote.RemoteObjectClass, remoteclient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 服务器 TcpServerChannel channel = new TcpServerChannel(8086); ChannelSe
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;
}
类库
namespace ClassLibrary1
{
public class Class1 : System.MarshalByRefObject
{
public string ad;
public int id;
}
}
如果调用方和被调用的RemoteObject类位于不同的命名空间中,则可能会发生此错误。尝试构建应用程序。如果您已经构建了它,请清理并重新生成。@benjamin answer修复了此问题,在Mono下,错误如下:System.Runtime.Remoting.RemotingException:无法从客户端类型“remote.RemoteObjectClass,remoteclient,Version=1.0.0,Culture=neutral,PublicKeyToken=null“到服务器类型”remote.RemoteObjectClass“非常感谢您提供此提示。我想知道为什么我会有这个例外!远程处理中使用的接口和/或对象必须位于同一名称空间内!