私は次のことを行い、以下のエラーメッセージを受け取りました:
エラーメッセージ:
タイプ 'System.AggregateException' の例外が mscorlib.dll で発生しましたが、ユーザー コードで処理されませんでした 追加情報: 1 つ以上のエラーが発生しました。この例外のハンドラがあれば、プログラムは安全に続行できます。
質問 :
a)レコードを取得したかっただけなので、上記のコードの問題と思われるもの。
b) WinRT または Windows ストア アプリで非同期メソッドを使用する必要がありますか?
c) 以下のコードは Navision からレコードを取得できますか?
---1------- Nav Web サービスにアクセスするための Windows ストア アプリ 1.1 WinRT アプリにサービス参照を追加 1.2 WinRT アプリに class1.cs を追加 private async void btnImportCustomer_Click(オブジェクト送信者, RoutedEventArgs e) { Task _asyncCustomer = Class1.Customer.Listing.GetAsyncRecords("Y007"); ### ここでエラーが発生しました: #### 文字列 g_strmsg = _asyncCustomer.Result.No + " “ +_asyncCustomer.Result.Name; } -----2------------- WinRT アプリ プロジェクト内での Class1.cs の使用: システムを使用する; System.Collections.Generic の使用; System.Linq を使用します。 System.Text を使用します。 System.Threading.Tasks の使用; 名前空間 MobileNAVSalesSystem { クラス Class1 { public static string _webserviceurlpage = "http://{0}:{1}/{2}/WS/{3}/Page/{4}"; public static string _webserviceurlcodeunit = "http://{0}:{1}/{2}/WS/{3}/Codeunit/{4}"; public static Uri _webserviceuripage = null; public static Uri _webserviceuricodeunit = null; #region 顧客 public クラス 顧客 { パブリック クラス カード { // カード タイプを処理する } public クラス リスト { public static wsCustomerList.Customer_List_PortClient GetService() { _webserviceuripage = new Uri(string.Format(_webserviceurlpage, "msxxx", "7047", "DynamicsNAV_xxx", Uri.EscapeDataString("Global xxx Pte. Ltd."), "Customer List")); System.ServiceModel.BasicHttpBinding _wSBinding = new System.ServiceModel.BasicHttpBinding(); _wSBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly; _wSBinding.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows; _wSBinding.MaxBufferSize = Int32.MaxValue; _wSBinding.MaxReceivedMessageSize = Int32.MaxValue; //_wSBinding.UseDefaultWebProxy = false; wsCustomerList.Customer_List_PortClient _ws = new wsCustomerList.Customer_List_PortClient(_wSBinding, new System.ServiceModel.EndpointAddress(_webserviceuripage)); _ws.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation; _ws.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("xxx","xxxx", "companyName"); _ws を返します。 } //-------------------------- 非同期メソッドの使用 public static async Task GetAsyncRecords(string _No) { wsCustomerList.Customer_List_PortClient _ws = GetService(); wsCustomerList.Customer_List _List = (await _ws.ReadAsync(_No)).Customer_List; if (_ws.State == System.ServiceModel.CommunicationState.Opened) await _ws.CloseAsync(); _List を返します。 } public static async Task GetAsyncRecords(wsCustomerList.Customer_List_Filter[] _filters) { wsCustomerList.Customer_List_PortClient _ws = GetService(); wsCustomerList.Customer_List[] _List; List _filterArray = 新しい List(); _filterArray.AddRange(_filters); _List = (await _ws.ReadMultipleAsync(_filterArray.ToArray(), null, 0)).ReadMultiple_Result1; if (_ws.State == System.ServiceModel.CommunicationState.Opened) await _ws.CloseAsync(); _List を返します。 } public static async Task GetAsyncRecords(wsCustomerList.Customer_List_Filter[] _filters, string _bookmarkkey) { wsCustomerList.Customer_List_PortClient _ws = GetService(); wsCustomerList.Customer_List[] _List; List _filterArray = 新しい List(); _filterArray.AddRange(_filters); _List = (await _ws.ReadMultipleAsync(_filterArray.ToArray(), _bookmarkkey, 0)).ReadMultiple_Result1; if (_ws.State == System.ServiceModel.CommunicationState.Opened) await _ws.CloseAsync(); _List を返します。 } public static async Task GetAsyncRecords(wsCustomerList.Customer_List_Filter[] _filters, string _bookmarkkey, int _setsize) { wsCustomerList.Customer_List_PortClient _ws = GetService(); wsCustomerList.Customer_List[] _List; List _filterArray = 新しい List(); _filterArray.AddRange(_filters); _List = (await _ws.ReadMultipleAsync(_filterArray.ToArray(), _bookmarkkey, _setsize)).ReadMultiple_Result1; if (_ws.State == System.ServiceModel.CommunicationState.Opened) await _ws.CloseAsync(); _List を返します。 } } } #endregion } //--- 名前空間の終了 }