如何在Windows 10 Universal App中使用WCF服务? [英] How to use WCF services in Windows 10 Universal App?

查看:55
本文介绍了如何在Windows 10 Universal App中使用WCF服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows 8.1应用程序使用WCF服务.我需要将我的应用程序移植到Windows 10 UWP应用程序.但不能添加服务参考.当我添加服务引用时,将显示以下消息:

My Windows 8.1 app uses WCF services. I need to port my app to Windows 10 UWP app. But cannot add service reference. This message appears when I add a service reference:

数据服务客户端代码生成失败.不支持指定的Windows Store Framework'.NETCore,Version = v5.0'.仅支持.NETCore 4.5及更高版本.

Data service client code-generation failed. Specified Windows Store Framework '.NETCore,Version=v5.0' is not supported. Only .NETCore 4.5 and above is supported.

如何解决我的问题?

推荐答案

感谢@gregkalapos

Thank you for @gregkalapos

1.创建Windows 8.1可移植类库

2.选择这样

3.将服务引用添加到新创建的库.然后将库引用到Windows 10 Universal App项目.

这是示例调用方法:

var client = new ConnectODataEntities(new Uri("http://...ODATA URL..."));
var dsQuery = (DataServiceQuery<YOUR_METHOD_RETURN_TYPE>)(client.YOUR_METHOD);

var tf = new TaskFactory<IEnumerable<YOUR_METHOD_RETURN_TYPE>>();
var list = (await tf.FromAsync(dsQuery.BeginExecute(null, null),
                            iar => dsQuery.EndExecute(iar))).ToList();



lbox.ItemsSource = list;

使用此方法的应用程序可在 Windows 10 Windows 10 Mobile

这篇关于如何在Windows 10 Universal App中使用WCF服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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