从.net 2.0使用WCF服务 [英] Consume WCF service from .net 2.0

查看:78
本文介绍了从.net 2.0使用WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从.net 2.0应用程序中使用WCF服务.我可以调用该服务,但只传递字符串值,所有整数和双精度数均为零,等等.当我从.Net 4.0应用程序调用该服务时,一切正常.有谁知道为什么只传递字符串值吗?

I''m having trouble consuming a WCF service from an .net 2.0 application. I can call the service but only string values are passed, all integer and doubles are zero etc. When i call the service from an .Net 4.0 application, everything works. Does any one have any ideas why only string values are passed?

推荐答案

我的想法是使用.NET Framework 3.5或更高版本.该框架是免费的可再分发的. 2.0版中没有WCF.

不使用较新版本的Framework并仍使用WCF服务的原因是什么?您只有Windows Studio 2005吗?您可以使用操作员源MonoDevelop(请参见 http://en.wikipedia.org/wiki/MonoDevelop [ ^ ], http://monodevelop.com/ [ ^ ]),免费Visual Studio Express( http://en.wikipedia.org/wiki/Visual_Studio_Express [http://www.microsoft.com/visualstudio/zh-cn/products/2010-editions/express [MSBuild.EXE solution-file.sln [options]"在不使用Studio的情况下构建任何解决方案.
我有一个替代方案,它可能不太容易实现,但您可以尝试.您可以尝试使用.NET 2.0将WCF的不同实现引入您的解决方案.您可以从Mono的源代码下载该库的源代码,然后将其准确地添加到您的解决方案中.问题是找出并检测所有源代码依赖项.参见:
http://en.wikipedia.org/wiki/Mono_%28software%29 [ ^ ],http://www.mono-project.com/Main_Page [ ^ ].

(听起来很吓人,但是我做了类似的调试操作.我想调试一些仅在Mono下运行但使用Visual Studio时有问题的软件.我从Mono来源下载了部分库代码并获得了混合代码—代码的一部分正在运行.NET库,并与从Mono中提取的代码一起使用,因此它替换了.NET代码.我设法一起运行它,并实际上解决了我的问题!)

—SA
My idea is to use .NET Framework 3.5 or later. The Framework is free re-distributable. There is no WCF in v. 2.0.

What''s the reason for not using more modern version of the Framework and still using WCF service? You only have Windows Studio 2005? You can use oper-source MonoDevelop (see http://en.wikipedia.org/wiki/MonoDevelop[^], http://monodevelop.com/[^]), free of charge Visual Studio Express (http://en.wikipedia.org/wiki/Visual_Studio_Express[^], http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express[^]) or develop without any IDE.

Last option is not so easy, but it''s possible, I tried. Major compilers, MSBuild.EXE and all other required tools are bundled with free-of-charge redistributable .NET Framework, not Visual Studio. By the way, you can build any solution without Studio using the command line "MSBuild.EXE solution-file.sln [options]".

I have an alternative idea which might not be so easy to implement, but you can try. You can try to introduce a different implementation of WCF into your solution using .NET 2.0. You can download source code of this library from the source code of Mono and accurately add it to your solution. The problem is to find out and detect all source-code dependencies. See:
http://en.wikipedia.org/wiki/Mono_%28software%29[^], http://www.mono-project.com/Main_Page[^].

(It sounds scary, but I did something like that for debugging purposes. I wanted to debug some software having a problem when running only under Mono but using Visual Studio. I download part of library code from Mono sources and obtained mixed code — part of code was running .NET libraries working together with code extracted from Mono, so it replaced .NET code. I managed to run it together and actually solved my problem!)

—SA


我将序列化从DataContract更改为XmlSerializerFormat,并且可以使用.奇怪的是它可以序列化字符串值.
I changed the serialization from DataContract to XmlSerializerFormat and it works. Strange that it could serialize the string values.


这篇关于从.net 2.0使用WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆