我在远程对象上定义了接口 ,在服务端进行了实现 。
经过编译后, 在本地建立虚拟目录。配置webconfig ,建立Bin文件夹copy服务dll
现在建立客户端时候,说无法连接远程服务, 谁有这方面经验帮我解决下 以下是部分代码,也只是做个例子
服务端:
public class Server : MarshalByRefObject, users
{
static void Main(string[] args)
{
IChannel tcp = new TcpChannel(8502);
ChannelServices.RegisterChannel(tcp, false); // 注册http通道
IChannel httpChnl = new HttpChannel(8505);
ChannelServices.RegisterChannel(httpChnl, false); Type t = typeof(users);
RemotingConfiguration.RegisterWellKnownServiceType(t, "UsersProvider", WellKnownObjectMode.SingleCall);
}
#region users 成员 bool users.Validate(User xuxl)
{
DataSet ds = sqlhelper.UserSet();
bool xx = false;
foreach (DataRow Dr in ds.Tables[0].Rows)
{
if (Dr["PUserName"].ToString() == xuxl.UserName && Dr["PUserID"].ToString() == xuxl.Pwd)
{
xx = true;
}
}
return xx;
}
#endregion }客户端 User xuxl = new User();
xuxl.UserName = "xuxl";
xuxl.Pwd = "123";
xuxl.IP = "192.168.111.29";
xuxl.Address = "hb";
string url = "http://localhost:8505/UsersProvider";
bool yy = false;
users test = (users)Activator.GetObject(typeof(users), url);
yy = test.Validate(xuxl);
Console.WriteLine(yy.ToString());
Console.ReadKey();
刚从书上接触的 ,希望大家能多给点宝贵建议 。。
没有权限??
我就在本地测试
访问返回结果
System.Runtime.Remoting.RemotingException: 无法加载类型“REM.Server, REM”。
在 System.Runtime.Remoting.RemotingConfigHandler.RemotingConfigInfo.LoadType(String typeName, String assemblyName)
在 System.Runtime.Remoting.RemotingConfigHandler.RemotingConfigInfo.GetServerTypeForUri(String URI)
在 System.Runtime.Remoting.RemotingConfigHandler.GetServerTypeForUri(String URI)
在 System.Runtime.Remoting.RemotingServices.GetServerTypeForUri(String URI)
在 System.Runtime.Remoting.Channels.Http.HttpRemotingHandler.CanServiceRequest(HttpContext context)
在 System.Runtime.Remoting.Channels.Http.HttpRemotingHandler.InternalProcessRequest(HttpContext context)这是什么意思