简体   繁体   中英

W8 Phone System.Xml.XmlException &

With this code it shows that there are no errors but when it is run it keeps crashing, Below is the code and then the debug output;

using System.Xml;
using System.Net;
using System.ServiceModel.Syndication;

XmlReaderSettings settings = new XmlReaderSettings();
        settings.DtdProcessing = DtdProcessing.Ignore;

        XmlReader reader = XmlReader.Create("https://news.google.com/news/feeds?pz=1&cf=all&ned=uk&hl=en&q=" + "google" + "&output=rss", settings);
        SyndicationFeed feed = SyndicationFeed.Load(reader);
        reader.Close();

This is the debug output:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.ArgumentException' occurred in System.Windows.ni.dll
'TaskHost.exe' (CoreCLR: 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
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in Microsoft.Phone.ni.dll

Call Stack info:

project.DLL!project.App.RootFrame_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e) Line 90 C# Microsoft.Phone.ni.dll!System.Windows.Navigation.NavigationService.RaiseNavigationFailed(System.Uri uri, System.Exception exception) Unknown Microsoft.Phone.ni.dll!System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(System.IAsyncResult result) Unknown Microsoft.Phone.ni.dll!System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(System.AsyncCallback userCallback, System.Windows.Navigation.PageResourceContentLoader.PageResourceContentLoaderAsyncResult result) Unknown Microsoft.Phone.ni.dll!System.Windows.Navigation.PageResourceContentLoader.BeginLoad.AnonymousMethod__0(object args) Unknown [Native to Managed Transition]
mscorlib.ni.dll!System.Delegate.DynamicInvokeImpl(object[] args) Unknown System.Windows.ni.dll!System.Windows.Threading.DispatcherOperation.Invoke() Unknown System.Windows.ni.dll!System.Windows.Threading.Dispatcher.Dispatch(System.Windows.Threading.DispatcherPriority priority) Unknown System.Windows.ni.dll!System.Windows.Threading.Dispatcher.OnInvoke(object context) Unknown System.Windows.ni.dll!System.Windows.Hosting.CallbackCookie.Invoke(object[] args) Unknown System.Windows.RuntimeHost.ni.dll!System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(System.IntPtr pHandle, int nParamCount, System.Windows.Hosting.NativeMethods.ScriptParam* pParams, System.Windows.Hosting.NativeMethods.ScriptParam* pResult) Unknown

Thank you for your help

public void FileDownloadComplete(object sender, DownloadStringCompletedEventArgs e) { // e.Result will contain the files byte for byte

// your settings
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Ignore;

// create a memory stream for us to use from the bytes of the downloaded file
MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(e.Result ?? ""));

// create your reader from the stream of bytes
XmlReader reader = XmlReader.Create(ms, settings);

// do whatever you want with the reader
// ........

// close
reader.Close()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM