web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

What is this msg when accessing NAV web service with Windows 8 app

(0) ShareShare
ReportReport
Posted on by

I did the following and got the below error msg:

The error message :

An exception of type 'System.AggregateException' occurred in mscorlib.dll but was not handled in user code

Additional information: One or more errors occurred.

If there is a handler for this exception, the program may be safely continued.

Question :

a)  What seems to be the problems in above code as I just wanted to retrieve a record.

b) Must use Async Methods in WinRT or Windows store app?

c) Will below code able to retrieve record from Navision?

-----1-------  Windows store App to access Nav Web Services

1.1 Added the service reference  in WinRT App

1.2 Added a class1.cs in WinRT App

private async void btnImportCustomer_Click(object sender, RoutedEventArgs e)

{

   Task<wsCustomerList.Customer_List> _asyncCustomer = Class1.Customer.Listing.GetAsyncRecords("Y007");

   ###  encounterd error here: ####

  string  g_strmsg = _asyncCustomer.Result.No + " “ +_asyncCustomer.Result.Name;

}

-----2----------     Class1.cs use inside WinRT App Project:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace MobileNAVSalesSystem

{

   class 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 Customer

       public class Customer

       {

           public class Card

           {

               //Do something for Card Type

           }

           public class Listing

           {

               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");

                   return _ws;

               }

  //-------------------------- Using Async Methods

    public static async Task<wsCustomerList.Customer_List> 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();

                   return _List;

     }

 public static async Task<wsCustomerList.Customer_List[]> GetAsyncRecords(wsCustomerList.Customer_List_Filter[] _filters)

    {

           wsCustomerList.Customer_List_PortClient _ws = GetService();

            wsCustomerList.Customer_List[] _List;

            List<wsCustomerList.Customer_List_Filter> _filterArray = new List<wsCustomerList.Customer_List_Filter>();

                   _filterArray.AddRange(_filters);

                   _List = (await _ws.ReadMultipleAsync(_filterArray.ToArray(), null, 0)).ReadMultiple_Result1;

            if (_ws.State == System.ServiceModel.CommunicationState.Opened)

                       await _ws.CloseAsync();

                      return _List;

               }

 public static async Task<wsCustomerList.Customer_List[]> GetAsyncRecords(wsCustomerList.Customer_List_Filter[] _filters, string _bookmarkkey)

    {

       wsCustomerList.Customer_List_PortClient _ws = GetService();

       wsCustomerList.Customer_List[] _List;

                   List<wsCustomerList.Customer_List_Filter> _filterArray = new List<wsCustomerList.Customer_List_Filter>();

       _filterArray.AddRange(_filters);

      _List = (await _ws.ReadMultipleAsync(_filterArray.ToArray(), _bookmarkkey, 0)).ReadMultiple_Result1;

       if (_ws.State == System.ServiceModel.CommunicationState.Opened)

                 await _ws.CloseAsync();

               return _List;

       }

 public static async Task<wsCustomerList.Customer_List[]> GetAsyncRecords(wsCustomerList.Customer_List_Filter[] _filters, string _bookmarkkey, int _setsize)

   {

          wsCustomerList.Customer_List_PortClient _ws = GetService();

          wsCustomerList.Customer_List[] _List;

           List<wsCustomerList.Customer_List_Filter> _filterArray = new List<wsCustomerList.Customer_List_Filter>();

                   _filterArray.AddRange(_filters);

          _List = (await _ws.ReadMultipleAsync(_filterArray.ToArray(), _bookmarkkey, _setsize)).ReadMultiple_Result1;

           if (_ws.State == System.ServiceModel.CommunicationState.Opened)

                       await _ws.CloseAsync();

                   return _List;

               }

           }

       }

       #endregion

   }

//--- end namespace

}

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: What is this msg when accessing NAV web service with Windows 8 app

    I used try -catch statement. It shows this error msg  as below:

    one or more errors

    I want to know will my Code work and is the way I handle the returned result correctly?

  • Suggested answer
    Aleksandar Totovic Profile Picture
    16,765 on at
    RE: What is this msg when accessing NAV web service with Windows 8 app

    Maybe you can find a help on:

    msdn.microsoft.com/.../system.aggregateexception.aspx

    stackoverflow.com/.../how-to-fix-system-aggregateexception-occurred-in-mscorlib-dll

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#2
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans