类型' System.Reflection.TargetInvocationException'的例外情况发生在System.ni.dll中(与之前的网连接相同)

时间:2014-07-12 05:42:12

标签: c# windows windows-phone-8

public partial class Page2 : PhoneApplicationPage
    {
        public Page2()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();
        }
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            List transactionList = new List();
            WebClient webClient = new WebClient();
            webClient.DownloadStringAsync(new Uri("URI"));
            webClient.DownloadStringCompleted += (Object senders, DownloadStringCompletedEventArgs es) =>
            {
                string json_arr = es.Result;
                /*the above statement throws the following exception.
"An exception of type 'System.Reflection.TargetInvocationException' occurred in System.ni.dll but was not handled in user code"*/
                if (es.Error == null)
                {
                    JArray jsonarray = JArray.Parse(json_arr);
                    for (int i = 0; i ("str1");
                        String str2= jsonarray[i].Value("str2");
                        String str3= jsonarray[i].Value("str3");
                        String str4= jsonarray[i].Value("str4");
                        String str5= jsonarray[i].Value("str5");
                        transactionList.Add(new name(str1,str2,str3,str4,str5));
                    }
                    TransactionList.ItemsSource = transactionList;
                }
            };
        }
    }

0 个答案:

没有答案