高分求救!!!关于Remoting,如何调用两个远程对象

kintsoon 2004-06-14 09:28:03
我在服务器上有两个提供不同服务的类,分别封装在两个.dll文件中,我如何让服务器端同时提供这两个类的服务给客户端来使用.

我原来想只要在配置文件中加个wellknown 节点就可以,但是不行.提示的错误也让人一头雾水.谁帮我看看.....谢谢!


服务器端源码:

using System;
using System.Runtime.Remoting;

namespace Server.Server
{
class ServerStartup
{
public static void Main(String[] args)
{
RemotingConfiguration.Configure("server.exe.config");

Console.WriteLine("Press <return> to exit");
Console.ReadLine();

}
}
}

服务器端配置文件:
<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="CDBAccess.AllAboutDataBase.CDBAccess, AllAboutDataBase"
objectUri="Broadcast"
/>
</service>
<service>
<wellknown
mode="Singleton"
type="FileTrans.CFileTrans, FileTrans"
objectUri="Broadcast"
/>
</service>
<channels>
<channel
ref="http"
port="9990"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>



客户端配置文件:
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown
type="CDBAccess.AllAboutDataBase.CDBAccess, AllAboutDataBase"
url="http://192.168.0.168:9990/Broadcast"
/>
</client>
<client>
<wellknown
type="FileTrans.CFileTrans, FileTrans"
url="http://192.168.0.168:9990/Broadcast"
/>
</client>
<channels>
<channel
ref="http"
port="0"
/>
</channels>
</application>
</system.runtime.remoting>
</configuration>


错误信息:

{System.Runtime.Remoting.RemotingException}
[System.Runtime.Remoting.RemotingException]: {System.Runtime.Remoting.RemotingException}
HelpLink: Nothing
InnerException: Nothing
Message: "试图在公开 FileTrans.CFileTrans 的对象上调用类型 CDBAccess.AllAboutDataBase.CDBAccess 上声明的方法。"
Source: "mscorlib"
StackTrace: "
Server stack trace:
at System.Runtime.Remoting.Messaging.StackBuilderSink.VerifyIsOkToCallMethod(Object server, IMethodMessage msg)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at CDBAccess.AllAboutDataBase.CDBAccess.ValidateUserPsw(String strXml) in e:\code\allaboutdatabase\allaboutdatabase\cdbaccess.cs:line 1053
at Console.app.ValidatePassWord(String astrUserCode, String astrPassword) in E:\code\app.vb:line 135"
TargetSite: {System.Reflection.RuntimeMethodInfo}
...全文
158 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yemao20 2004-06-14
  • 打赏
  • 举报
回复
UP
kintsoon 2004-06-14
  • 打赏
  • 举报
回复
up
kintsoon 2004-06-14
  • 打赏
  • 举报
回复
搞定了.
原来是因为两个objectUri的值一样.将之区分开,然后在客户端也做下改动即可

SERVER:
<service>
<wellknown
mode="Singleton"
type="CDBAccess.AllAboutDataBase.CDBAccess, AllAboutDataBase"
objectUri="AllAboutDataBase"
/>
</service>
<service>
<wellknown
mode="Singleton"
type="FileTrans.CFileTrans, FileTrans"
objectUri="FileTrans"
/>
</service>

CLIENT:
<client>
<wellknown
type="CDBAccess.AllAboutDataBase.CDBAccess, AllAboutDataBase"
url="http://192.168.0.168:9990/AllAboutDataBase"
/>
</client>
<client>
<wellknown
type="FileTrans.CFileTrans, FileTrans"
url="http://192.168.0.168:9990/FileTrans"
/>
</client>

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧