簡體   English   中英

使用WCF數據服務的Windows Phone 8中,LoadAsync不起作用

[英]LoadAsync doesn't work in windows phone 8 with WCF data service

我和我的朋友剛剛創建了WCF數據服務,並希望通過Windows Phone 8客戶端使用它。 對於WCF數據服務部分,已證明OData可與Windows Form項目一起使用,該項目對數據庫執行CRUD。

因此,要使WP8消耗WCF數據服務,我們逐步按照本教程進行操作,並在MSDN教程http://msdn.microsoft.com/zh-cn/library/windows/apps/hh394007(v=vs .105).aspx

但是,這些示例不起作用。電話上沒有顯示數據庫中的數據。

我們在MainViewModel Class中的public void LoadData函數下找到Customers.LoadAsync(Query) ,不會在以下位置加載XML數據: http : //services.odata.org/Northwind/Northwind.svc/Customers()

public void LoadData()
        {
            // Instantiate the context and binding collection.
            _context = new NorthwindEntities(_rootUri);
            Customers = new DataServiceCollection<Customer>(_context);

            // Specify an OData query that returns all customers.
            var query = from cust in _context.Customers
                        select cust;

            // Load the customer data.
            Customers.LoadAsync(query);
        }

我們修改了函數OnCustomerLoaded以顯示錯誤消息(如果存在):

private void OnCustomersLoaded(object sender, LoadCompletedEventArgs e)
        {
            if (e.Error != null)
            {

                MessageBox.Show(e.Error.Message+e.Error.InnerException);

            }
            // Make sure that we load all pages of the Customers feed.
            if (Staffs.Continuation != null)
            {
                Staffs.LoadNextPartialSetAsync();
            }
            //MessageBox.Show(Staffs.ToString());
            IsDataLoaded = true;
        }

我們收到以下錯誤:

LoadAsync方法出錯

我們使用的是VS2012 premium,使用OData 5.0.0創建了具有數據綁定項目的Windows Phone 8。

我們必須承認該錯誤可能不是問題的根本原因,但是由於我們是新手,所以我們無法弄清楚。 如果有人可以指出,如果不是錯誤根源,我們將進行哪些更改以使示例正常工作,我們深表感謝。

非常感謝!!

看來您的應用無法訪問互聯網,可能是由WP Emulator的設置問題引起的。

您可以先嘗試使用內置的Internet Explorer,然后檢查它是否可以訪問Internet。 如果不是,則可以轉到Hyper-V配置頁面,然后嘗試更改網絡適配器設置,或參考以下頁面了解詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM