2014-10-25 9 views
1

С помощью этого кода он показывает, что ошибок нет, но когда он запускается, он продолжает сбой, Ниже приведен код, а затем вывод отладки;W8 Phone System.Xml.XmlException &

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

Это отладочный вывод:

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 Информация:

project.DLL project.App.RootFrame_NavigationFailed (объект отправителя, System.Windows.Navigation.NavigationFailedEventArgs e) Линия 90 C# Microsoft.Phone.ni.dll! System.Windows.Navigation.NavigationService.RaiseNavigationFailed (Исключение системы System.Uri, исключение System.Exception) Неизвестно Micr osoft.Phone.ni.dll! System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback (Результат System.IAsyncResult) Неизвестно Microsoft.Phone.ni.dll! System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread (System.AsyncCallback userCallback, System. результат Windows.Navigation.PageResourceContentLoader.PageResourceContentLoaderAsyncResult) Неизвестно Microsoft.Phone.ni.dll! System.Windows.Navigation.PageResourceContentLoader.BeginLoad.AnonymousMethod__0 (объект арг) Неизвестный [Род Managed Перехода]
mscorlib.ni.dll! System.Delegate.DynamicInvokeImpl (object [] args) Неизвестно System.Windows.ni.dll! System.Windows.Threading.DispatcherOperation.Invoke() Неизвестно System.Windows.ni.dll! System.Windows.Threading.Dispatcher. Отправка (System.Windows.Threading. DispatcherPriority priority) Неизвестно System.Windows.ni.dll! System.Windows.Threading.Dispatcher.OnInvoke (контекст объекта) Неизвестно System.Windows.ni.dll! System.Windows.Hosting.CallbackCookie.Invoke (object [] args) Неизвестно 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) Неизвестный

Спасибо за вашу помощь

+0

ли файл, который вы хотите прочитать существует? –

+0

@Arpad Да, [это] (https://news.google.com/news/feeds?pz=1&cf=all&ned=uk&hl=ru&q=google&output=rss). Я попробовал, и это работает. –

+0

Он показывает случайное исключение типа «System.IO.FileNotFoundException», произошедшее в ошибке mscorlib.ni.dll при запуске @LajosArpad – user3795349

ответ

1

общественности недействительным FileDownloadComplete (объект отправителя, DownloadStringCompletedEventArgs е) { // e.Result будет содержать файлы побайтно

// 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()