无法加载类型错误,.Net Remoting
我正在尝试制作一个简单的程序,将 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;
}
}
i am trying to make a simple program that sends an id as an int and gets the data according to id. But i keep getting this error.
Cannot load type 'remote.RemoteObjectClass, remoteclient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
Server
TcpServerChannel channel = new TcpServerChannel(8086);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Class1), "1",
WellKnownObjectMode.Singleton);
label1.Text = "started";
Client
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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果调用者和被调用的 RemoteObject 类位于不同的命名空间中,则可能会发生此错误。
This error may happen if the Caller and Called RemoteObject Classes are in different namespaces.