How to use WCF services in Windows 10 Universal App?

后端 未结 2 1983
旧巷少年郎
旧巷少年郎 2020-12-30 10:35

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:

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 11:00

    Thank you for @gregkalapos

    1. Create Windows 8.1 Portable class library

    2. Choose like this

    3. Add Service Reference to newly created library. Then reference library to Windows 10 Universal App project.

    This is example call method:

    var client = new ConnectODataEntities(new Uri("http://...ODATA URL..."));
    var dsQuery = (DataServiceQuery)(client.YOUR_METHOD);
    
    var tf = new TaskFactory>();
    var list = (await tf.FromAsync(dsQuery.BeginExecute(null, null),
                                iar => dsQuery.EndExecute(iar))).ToList();
    
    
    
    lbox.ItemsSource = list;
    

    This method used app works on Windows 10 and Windows 10 Mobile

提交回复
热议问题