3
我想做一個簡單的程序,發送一個id作爲一個int,並根據id獲取數據。但我不斷收到這個錯誤。無法加載類型錯誤,.Net Remoting
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;
}
}
嘗試構建應用程序。如果您已經構建它,請清理並*重建*。 – 2011-04-02 13:40:45
問題使用@benjamin answer在Mono下解決,錯誤如下:System.Runtime.Remoting.RemotingException:無法從客戶端類型'remote.RemoteObjectClass,remoteclient,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null'轉換爲服務器類型'remote.RemoteObjectClass' – 2012-09-14 14:32:14