如何在Windows 10 Universal App中使用WCF服务?

编程入门 行业动态 更新时间:2024-10-27 18:21: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("...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服务?

本文发布于:2023-11-06 04:16:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562694.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   Windows   WCF   App   Universal

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!