0

I am Facing an Exceptional error as shown below

'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Net.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs{00C6B4E0-1F82-4D23-9C2D-A1E2386F73FB}\Install\parsing.DLL'. Symbols loaded. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Core.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.Linq.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\System.Xml.debug.resources.DLL'. Module was built without symbols. A first chance exception of type 'System.Xml.XmlException' occurred in System.Xml.ni.dll An exception of type 'System.Xml.XmlException' occurred in System.Xml.ni.dll but was not handled in user code The program '[2380] TaskHost.exe' has exited with code -1 (0xffffffff).

The code used for parsing is

            string url1 = "http://maps.googleapis.com/maps/api/geocode/xml?address=Bangalore&sensor=false";



            XDocument doc = XDocument.Parse(url1);
            var lat = doc.Descendants(XName.Get("lat", url1)).FirstOrDefault();
            result.Text = (string)lat;

I am Facing the error at line XDocument.Parse(url1); Could you please help me to overcome this exception as I am Very new to this field

8
  • 1
    Insetad of GETTING the XML from the URL in your url1 variable, you're trying to parse the URL ITSELF - that can't work. Commented Mar 27, 2014 at 6:25
  • I used XDocument.Load(url1) method too,but still it threw the same exception.Could you provide me the correct parsing method/code,Thanks Commented Mar 27, 2014 at 6:29
  • Refer this Commented Mar 27, 2014 at 6:44
  • There is no definition for porxy.DownloadData() error is thrown.Am I missing any namespace?? Commented Mar 27, 2014 at 7:19
  • @LakshmiNarayanan The link which you specified in that they have used proxy.DownloadData() method,But there isnt any method as such,Kindly Help Commented Mar 27, 2014 at 10:11

2 Answers 2

2

XDocument.Parse(str) is parse the param string in parse method. and the XDocument.Load method means to load a file in your XAP package. but you want to load a xml file from web site. you can send request to the url and read response, then parse it. like this:

string url1 = "http://maps.googleapis.com/maps/api/geocode/xml?address=Bangalore&sensor=false";
string content = await HttpHelper.GetResponse(url1);
XDocument doc = XDocument.Parse(content);
var lat = doc.Descendants(XName.Get("lat")).FirstOrDefault();
result.Text = (string)lat;

the getResponse method here:

public async static Task<string> GetResponse(string url)
{
    try
    {
        WebRequest request = HttpWebRequest.Create(url);
        request.ContentType = "application/xml";
        WebResponse response = await request.GetResponseAsync();
        StreamReader reader = new StreamReader(response.GetResponseStream());
        string content = reader.ReadToEnd();
        reader.Dispose();
        response.Dispose();
        return content;
    }
    catch
    {
        return "";
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

sorry but what do you mean?
0

try this instead

string url1 = "http://maps.googleapis.com/maps/api/geocode/xml?address=Bangalore&sensor=false";
string content = await HttpHelper.GetResponse(url1);
XDocument doc = XDocument.Parse(content);
var lat = doc.Descendants(XName.Get("lat")).FirstOrDefault();
result.Text = (string)lat;

1 Comment

Welcome to Stack Overflow! Please consider including some information about your answer, rather than simply posting code. We try to provide not just 'fixes', but help people learn. You should explain what was wrong in the original code, what you did differently, and why your change(s) worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.