首页 新闻 赞助 找找看

Remoting客户端配置的问题,快来人呀,求助!!!!

0
悬赏园豆:100 [已解决问题] 解决于 2014-11-25 21:46

服务端对象:ClassLibrary.Calculate,ClassLibrary ,命名空间ClassLibrary,类名Calculate,程序集名称:ClassLibrary 

服务端 Remoting 配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="http" port="8086"/>
</channels>
<service>
<wellknown mode="Singleton"
   type="ClassLibrary.Calculate,ClassLibrary"
   objectUri="Calculate" />
</service>
</application>
</system.runtime.remoting>
</configuration>

服务端代码:

  RemotingConfiguration.Configure("Server.exe.config", false);
  Console.WriteLine("HTTP通道建立,名称:{0}", ChannelServices.RegisteredChannels.First().ChannelName);

运行服务端,服务端创建通道成功,IE中输入http://localhost:8086/Calculate?wsdl 能查看到对应的wsdl

客户端 Remoting 配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknow type="ClassLibrary.Calculate,ClassLibrary"
  url="http://localhost:8086/Calculate"/>
</client>
<channels>
<channel ref="http" port="0"/>
</channels>
</application>
</system.runtime.remoting>
</configuration>

客户端代码:
            RemotingConfiguration.Configure("Client.exe.config", false);       
            Calculate obj = new Calculate();
但这里生成的obj并不是一个proxy,我很奇怪,配置文件没有问题呀,如下图:

引用

我换种写法,客户端不用配置文件,如下:
            RemotingConfiguration.RegisterWellKnownClientType(typeof(Calculate), "http://localhost:8086/Calculate");
            Calculate obj = new Calculate();
这样的写法又是正常的,如下:


这是为什么呀?客户端的配置文件我真看不出来哪里有问题,就这么几行东西,谁给解答一下呀

July_Lee的主页 July_Lee | 初学一级 | 园豆:114
提问于:2014-11-25 14:26
< >
分享
最佳答案
0

自己顶一个,来人呀

July_Lee | 初学一级 |园豆:114 | 2014-11-25 15:41
Mr.Brian | 园豆:1518 (小虾三级) | 2014-11-25 16:49

@Mr.Brian: 你可以按照上面我给你的网址,你把代码调整一下。然后反复调试,仔细观察他们之间的区别。

Mr.Brian | 园豆:1518 (小虾三级) | 2014-11-25 16:56

@Mr.Brian: 大哥,你的文章写的很好,但我没发现能解决这个问题呀

July_Lee | 园豆:114 (初学一级) | 2014-11-25 20:02

@July_Lee: 我按照你这里说的没有重现你的问题,我也看了你的代码确实没错,但是我这边和你看到的结果不一样,你可以下载我博客中的代码:http://www.cnblogs.com/zhili/p/NETRemoting.html#3071568看下,我用你第一种方式还是一样获得的是代理对象,如下图所示:

Learning hard | 园豆:362 (菜鸟二级) | 2014-11-25 20:46

@Learning hard: 问题已找到,是我客户端中配置<wellknown/>节点写成了<wellknow/> 造成的,手误害死人,谢谢了!

July_Lee | 园豆:114 (初学一级) | 2014-11-25 21:45
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册