Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7763909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:46:42+00:00 2026-06-01T14:46:42+00:00

I have a windows phone 7.1 app that tries to get data from a

  • 0

I have a windows phone 7.1 app that tries to get data from a web service. The data is in XML format. Language is vb.net under Visual Studio 2010 with the Async CTP 3.

I have successfully retrieved the response from the web service and parsed the string into an XDocument. But I have problem when trying to populate a viewmodel by looping through the XML because the loop variable contains nothing (I want it to contain XElement):

Private Async Function GetMovies() As Task
    Dim client As New WebClient
    Dim address = (New Uri(New Uri(APIROOT), "movieschedule/movies")).ToString

    Dim resulttxt = Await client.DownloadStringTaskAsync(address)

    Dim resultdoc = XDocument.Parse(resulttxt)
    Dim resultlist As New Collections.ObjectModel.ObservableCollection(Of Movies)
    For Each movie In resultdoc.Descendants("movie")

        ' **the variable 'movie' contains nothing**

        Dim m As New Movies With {
            .Cast = movie.Attribute("cast").Value,
            ...
            .Title = movie.Attribute("title").Value
        }
        resultlist.Add(m)
    Next

    Movies = resultlist
End Function

Example of XML from the web service:

<movies>
  <movie code="MOV1299" title="Age of Heroes" is3D="0" genre="THRILLER" rating="D" cast="Sean Bean, Danny Dyer, Izabella Miko, James D'Arcy, Sebastian Street, William Houston" director="Adrian Vitoria" language="ENGLISH" subtitle="BAHASA INDONESIA" />
  <movie code="MOV1325" title="Fast and Furious 5" is3D="0" genre="ACTION" rating="D" cast="Vin Diesel, Paul Walker, Dwayne Johnson, Jordana Brewster, Tyrese Gibson, Elsa Pataky" director="Justin Lin" language="ENGLISH" subtitle="BAHASA INDONESIA" />
</movies>

I have put a breakpoint on the line that creates new Movies. I can confirm variable resultdoc is populated. I tried in the immediate window resultdoc.Descendants("movie").Count returned 15. resultdoc.Descendants("movie").First.Attribute("code").Value correctly returned “MOV1299”.

I got this error when I continued from the breakpoint:

System.NullReferenceException was unhandled
  Message=NullReferenceException
  StackTrace:
       at MyApp.MainPageVM.VB$StateMachine_2_GetMovies.MoveNext()
       at System.Runtime.CompilerServices.TaskAwaiter.<>c__DisplayClass5.<OnCompletedInternal>b__1(Object state)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at System.Delegate.DynamicInvokeOne(Object[] args)
       at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
       at System.Delegate.DynamicInvoke(Object[] args)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
       at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
       at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
       at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
       at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

Why the variable movie contains nothing? How do I make it contain the proper XElement from resultdoc.Descendants("movie")?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:46:44+00:00Added an answer on June 1, 2026 at 2:46 pm

    [Copied down from the comment]

    Go to the Exceptions dialog box (should be under the debug menu) and select to break when NullReferenceException is thrown. You will see exactly where the error is. What may be happening is that one of the XML nodes you are getting back from the server does not have a title or cast or one of the other attribute on them and you are dying on that

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a windows phone 7 app that communicates with a web service. i've
I have a Silverlight Windows Phone 7 app that pulls data from a public
I have a Windows Phone app that relies on an XML data file that
I have a Windows Phone 7 app that (currently) calls an OData service to
I'm writing a Windows Phone app in C#. I have a setting OrientationLock that
I'm using Hammock in a Windows Phone app to request data from a REST
I have in my Windows Phone app several images that are binded to uri's
I hope this makes sense. I have a Windows Phone 7 app that is
I'm working on a Windows Phone 7 app that requires some data encryption. I'm
I have a windows phone 7 app with some xaml that looks like: <Grid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.