remoting使用手记(2)

王朝other·作者佚名  2006-01-09
宽屏版  字体: |||超大  

开始以为我的Remoting配置基本可以了,可最近又出现了一些问题,自己进行简单的摸索和实践,记录如下。

8 、发现自己的数据库连接类ConnectionInfo在web service中作为参数出现无法序列化的错误,由于有public的属性是CultureInfo 的,无法实现序列化(由于CultureInfo 没有实现ISerializable接口),只好把类型改为string;既然remoting调用远程对象时不便于调试,所以可以先把需要序列化的类用Web Service调试通过再使用,也是一种调试remoting的方法;

9、前面说到出现错误“由于安全限制,无法访问对象”的错误,和强名有关,其实那不是真正的解决办法;可以通过在配置文件中设置 typeFilterLevel="Full" 来解决,客户端和服务器端的配置文件都需要设置。参见:http://www.thinktecture.com/Resources/RemotingFAQ/Changes2003.html

You can do this either by using a configuration file like this (for server side):

<configuration>

<system.runtime.remoting>

<application>

<channels>

<channel ref="http" port="1234">

<serverProviders>

<provider ref="wsdl" />

<formatter ref="soap" typeFilterLevel="Full" />

<formatter ref="binary" typeFilterLevel="Full" />

</serverProviders>

<clientProviders>

<formatter ref="binary" />

</clientProviders>

</channel>

</channels>

<service>

<!-- ... Add your services here ... -->

</service>

</application>

</system.runtime.remoting>

</configuration>

In this case, a matching client-side configuration file which allows the reception of events and callbacks, would look like this:

<configuration>

<system.runtime.remoting>

<application>

<channels>

<channel ref="http" port="0">

<clientProviders>

<formatter ref="binary" />

</clientProviders>

<serverProviders>

<formatter ref="binary" typeFilterLevel="Full" />

</serverProviders>

</channel>

</channels>

<client>

<!-- ... Add your classes here ... -->

</client>

</application>

</system.runtime.remoting>

</configuration>

10、按照如上的格式进行配置文件的修改后,终于不出现“由于安全限制,无法访问对象”的错误了,可是出现

“mscorlib.dll 中出现无法处理的异常类型 System.Runtime.Serialization. SerializationException。

其他信息:BinaryFormatter 版本不兼容。收到的版本为 1008738336.1684104552”的错误,

这种错误大部分“不是”因为版本不兼容,而是因为客户端无法分析文本格式的错误响应。为了真正的错误信息,我把

格式程序从binary改为soap。

11、把需要序列化的类ConnectionInfo和其他remoting远程类一样,添加到配置文件中(服务器端Web.Config中的<service>

节和客户端配置文件中),哈哈,终于通过了。(不过我还是没明白序列化的类为何也要进行配置?)

12、发现静态(static)的方法即使进行Remoting配置,调用的竟然是本的方法,看来如果需要调用远程的static方法,

只有再封装成实例方法供客户端调用了。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有