Processing Linq XML string - c#

I need to parse XML string with Linq, and I came up with the following code.
using System;
using System.Linq;
using System.Xml.Linq;
class LinqXml
{
public void Parse(string input)
{
XDocument xdoc = XDocument.Load(input);
var lang = from d in xdoc.Elements("PipeUnit").Elements("Step").Elements("Pipelist").Elements("NamedPipe").Elements("NameOfPipe") select d;
Console.WriteLine(lang.First().Value);
foreach (var item in lang)
{
Console.WriteLine(item.Value);
}
}
static void Main()
{
string tempString = #"
<PipeUnit>
<Step>
<Pipelist>
<NamedPipe>
<NameOfPipe>Name</NameOfPipe>
<PipeData>Data</PipeData>
</NamedPipe>
</Pipelist>
</Step>
</PipeUnit>
";
var linqXml = new LinqXml();
linqXml.Parse(tempString);
}
}
When compile this code with Mono - dmcs linqxml.cs /r:System.Xml.Linq.dll, and tried to run, I got the following errors.
Unhandled Exception: System.IO.DirectoryNotFoundException: Could not find a part of the path "/Users/smcho/Desktop/csharp/
<PipeUnit>
<Step>
<Pipelist>
<NamedPipe>
<NameOfPipe>Name</NameOfPipe>
<PipeData>Data</PipeData>
</NamedPipe>
</Pipelist>
</Step>
<PipeUnit>".
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
at System.Xml.XmlUrlResolver.GetEntity (System.Uri absoluteUri, System.String role, System.Type ofObjectToReturn) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.GetStreamFromUrl (System.String url, System.String& absoluteUriString) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader..ctor (Boolean dummy, System.Xml.XmlResolver resolver, System.String url, XmlNodeType fragType, System.Xml.XmlParserContext context) [0x00000] in <filename unknown>:0
at System.Xml.XmlTextReader..ctor (Boolean dummy, System.Xml.XmlResolver resolver, System.String url, XmlNodeType fragType, System.Xml.XmlParserContext context) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String url, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext context) [0x00000] in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String url, System.Xml.XmlReaderSettings settings) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri) [0x00000] in <filename unknown>:0
at LinqXml.Parse (System.String input) [0x00000] in <filename unknown>:0
at LinqXml.Main () [0x00000] in <filename unknown>:0
What might be wrong?

Replace this:
XDocument xdoc = XDocument.Load(input);
with:
XDocument xdoc = XDocument.Parse(input);
you are passing XML, not a file name.

in your Parse method, you want
XDocument.Parse(input)

Replace
XDocument xdoc = XDocument.Load(input);
with
XDocument xdoc = XDocument.Parse(input);

Related

PING ERROR C# - Parameter name: hostName

I need help.. I checking for if user of PC connected to Internet..
It works for me.. and for many people.. But for someone no
and it's writing this into output_log.txt
ERROR:
ArgumentNullException: Argument cannot be null.
Parameter name: hostName
at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.GetNonLoopbackIP () [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.SendPrivileged (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.Net.IPAddress address, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, Int32 timeout, System.Byte[] buffer, System.Net.NetworkInformation.PingOptions options) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, Int32 timeout, System.Byte[] buffer) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress, Int32 timeout) [0x00000] in <filename unknown>:0
at System.Net.NetworkInformation.Ping.Send (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Net.NetworkInformation.Ping:Send (string)
at Internet.Connection.Check () [0x00000] in <filename unknown>:0
at MyGame.Load.Loader.StartLoading () [0x00000] in <filename unknown>:0
at Loader+<Start>c__IteratorA.MoveNext () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
Code:
namespace Internet
{
using System;
using System.Net.NetworkInformation;
using UnityEngine;
public class Connection
{
public static void Check()
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
if (ping.Send("89.203.249.74").Status != IPStatus.Success)
{
Debug.Log("NO INTERNET CONNECTION");
Application.Quit();
}
}
}
}
So Please help

Strange UriFormatException when using mono

I'm currently working on a project which has to run on mono.
Normally, everything works just fine. But when I try to run it in a separate screen on my ubuntu 14.04 server, it won't start after crashing once. The error that occurs is the following:
System.UriFormatException: Invalid URI: The URI scheme is not valid.
at System.Uri.Parse (UriKind kind, System.String uriString) <0x40141e70 + 0x000b3> in <filename unknown>:0
at System.Uri.ParseUri (UriKind kind) <0x40141d50 + 0x00023> in <filename unknown>:0
at System.Uri..ctor (System.String uriString, Boolean dontEscape) <0x401459e0 + 0x001b7> in <filename unknown>:0
at System.Uri..ctor (System.String uriString) <0x401459b0 + 0x00013> in <filename unknown>:0
at System.Xml.XmlResolver.ResolveUri (System.Uri baseUri, System.String relativeUri) <0x401403f0 + 0x0010b> in <filename unknown>:0
at System.Xml.XmlUrlResolver.ResolveUri (System.Uri baseUri, System.String relativeUri) <0x401403c0 + 0x00017> in <filename unknown>:0
at System.Xml.XmlTextReaderImpl..ctor (System.String uriStr, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext context, System.Xml.XmlResolver uriResolver) <0x4013e610 + 0x00060> in <filename unknown>:0
at System.Xml.XmlReaderSettings.CreateReader (System.String inputUri, System.Xml.XmlParserContext inputContext) <0x4013e4a0 + 0x0008f> in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String inputUri, System.Xml.XmlReaderSettings settings, System.Xml.XmlParserContext inputContext) <0x4013e420 + 0x0005f> in <filename unknown>:0
at System.Xml.XmlReader.Create (System.String inputUri, System.Xml.XmlReaderSettings settings) <0x4013e3c0 + 0x00013> in <filename unknown>:0
at Project.Server.Settings..ctor () <0x4013c1f0 + 0x0006f> in <filename unknown>:0
This seems very strange to me, as the code that produces the error is the following:
private XDocument configFile;
public Settings()
{
var readerSettings = new XmlReaderSettings { CheckCharacters = false };
using (var reader = XmlReader.Create("config.xml", readerSettings))
{
configFile = XDocument.Load(reader);
}
}
As mentioned before, everything works just fine when run the first time. But after it crashed once, it won't start and crashes with this error. More strangely, I can fix the problem by terminating the screen and making a new one and running the exact same command.
Has anybody encountered something like this before? Is this something that can be prevented?

Can't get Razor MVC to work on Mono

I'm running through the tutorial here to build an ASP.NET MVC website: http://www.asp.net/mvc/overview/getting-started/introduction/adding-a-view. I'm not using MSVC, but MonoDevelop, as I'm on a Linux system.
I'm running into some issues when I tried to add a Razor view to My HelloWorld Controller's Index function. Right now, the code for Views/HelloWorld/Index.cshtml is this:
<h2>Index</h2>
<p>Hello from our View Template!</p>
The code for Controllers/HelloWorldController.cs's Index() function is this:
// GET: /HelloWorld/
public ActionResult Index()
{
return View();
}
But when I go to http://127.0.0.1:8080/HelloWorld/, I'm gettng a 500 error. It's returning this information:
System.InvalidOperationException
Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.WebPages.Razor.
Exception Stack Trace:
at System.Web.WebPages.Razor.WebRazorHostFactory.CreateFactory (System.String typeName) [0x00030] in <filename unknown>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (System.Collections.Concurrent.TKey key, System.Func`2 valueFactory) [0x00037] in <filename unknown>:0
at System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfigCore (System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup config, System.String virtualPath, System.String physicalPath) [0x0004f] in <filename unknown>:0
at System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig (System.String virtualPath, System.String physicalPath) [0x00038] in <filename unknown>:0
at System.Web.WebPages.Razor.WebRazorHostFactory.CreateHostFromConfig (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.Razor.RazorBuildProvider.GetHostFromConfig () [0x00006] in <filename unknown>:0
at System.Web.WebPages.Razor.RazorBuildProvider.CreateHost () [0x00000] in <filename unknown>:0
at System.Web.WebPages.Razor.RazorBuildProvider.get_Host () [0x00008] in <filename unknown>:0
at System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode () [0x00008] in <filename unknown>:0
at System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType () [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManagerDirectoryBuilder.GetBuildProviderCodeDomType (System.Web.Compilation.BuildProvider bp) [0x00000] in <filename unknown>:0
at System.Web.Compilation.BuildManagerDirectoryBuilder.AssignToGroup (System.Web.Compilation.BuildProvider buildProvider, System.Collections.Generic.List`1 groups) [0x0007a] in <filename unknown>:0
at System.Web.Compilation.BuildManagerDirectoryBuilder.Build (Boolean single) [0x00151] in <filename unknown>:0
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x00019] in <filename unknown>:0
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00063] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00040] in <filename unknown>:0
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00006] in <filename unknown>:0
at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.GetCompiledType (System.String virtualPath) [0x00000] in <filename unknown>:0
at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x0001c] in <filename unknown>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00080] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList`1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0000b] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList`1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0004f] in <filename unknown>:0
In my Web.config file, I had to set <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc...'s version tag from 5.2.0.0 to 5.2.3.0 to match my NuGet package version.

Exception thrown when using Mono+Aspose.Words running on ubuntu

I'm using Aspose.Words to convert a doc/docx file to a pdf file on ubuntu. Mono runtime has been installed. My code is below:
Document doc = new Document ("/data/upfile/test.docx");
doc.Save ("/data/upfile/test.pdf", SaveFormat.Pdf);
Somehow, when the second line of the code is executed, an error was thrown. The detail is below:
Unhandled Exception: System.ArgumentOutOfRangeException: startIndex +
length > this.length Parameter name: length at
System.String.Substring (Int32 startIndex, Int32 length) [0x00000] in
:0 at
x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String
xe4115acdf4fbfccc, Int32 x961016a387451f05) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8
(System.Object xa860e35844c20ac7) [0x00000] in :0
at x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6
(System.String x1f25abf5fb75e795, System.Object xa860e35844c20ac7)
[0x00000] in :0 at
x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2 () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in
:0 at
x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98
(Aspose.Words.Document x3664041d21d73fdc,
x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in
:0 at Aspose.Words.Document.UpdatePageLayout ()
[0x00000] in :0 at
Aspose.Words.Document.x410db0f4a89a6ef1 (Boolean x24af0daafcd8fb8c)
[0x00000] in :0 at
Aspose.Words.Document.get_xcde671c53995c411 () [0x00000] in :0 at Aspose.Words.Document.get_PageCount () [0x00000] in
:0 at
xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553
(x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2) [0x00000] in
:0 at Aspose.Words.Document.xf381a641001e6830
(System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc,
Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, SaveFormat saveFormat) [0x00000] in :0
at MonoTest.MainClass.Main (System.String[] args) [0x00000] in
:0 [ERROR] FATAL UNHANDLED EXCEPTION:
System.ArgumentOutOfRangeException: startIndex + length > this.length
Parameter name: length at System.String.Substring (Int32 startIndex,
Int32 length) [0x00000] in :0 at
x6c95d9cf46ff5f25.x0d299f323d241756.x3b67e683e83cab62 (System.String
xe4115acdf4fbfccc, Int32 x961016a387451f05) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x4469479613bec4d8
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x7be41bff00df2c71
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x699caa1974f95d1a
(Aspose.Words.Node xda5bf54deb817e37) [0x00000] in :0 at x4adf554d20d941a6.x50e6e6d123fa4a35.x21e4bd206d6231f8
(System.Object xa860e35844c20ac7) [0x00000] in :0
at x4adf554d20d941a6.x50e6e6d123fa4a35.xb5ef8a04e65b87e6
(System.String x1f25abf5fb75e795, System.Object xa860e35844c20ac7)
[0x00000] in :0 at
x59d6a4fc5007b7a4.xdeb77ea37ad74c56.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xbbf9a1ead81dd3a1 (System.String
x1f25abf5fb75e795, System.Object xa860e35844c20ac7) [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.xf3a1cfbffa44728c () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x47f176deff0d42e2 () [0x00000] in
:0 at
x59d6a4fc5007b7a4.x487cdc969fefe3d6.x83f07df6a659e05b () [0x00000] in
:0 at
x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98
(Aspose.Words.Document x3664041d21d73fdc,
x59d6a4fc5007b7a4.xdeb77ea37ad74c56 xdfde339da46db651) [0x00000] in
:0 at Aspose.Words.Document.UpdatePageLayout ()
[0x00000] in :0 at
Aspose.Words.Document.x410db0f4a89a6ef1 (Boolean x24af0daafcd8fb8c)
[0x00000] in :0 at
Aspose.Words.Document.get_xcde671c53995c411 () [0x00000] in :0 at Aspose.Words.Document.get_PageCount () [0x00000] in
:0 at
xf989f31a236ff98c.x6c74398bceb133f8.xa2e0b7f7da663553
(x28925c9b27b37a46.x8556eed81191af11 x5ac1382edb7bf2c2) [0x00000] in
:0 at Aspose.Words.Document.xf381a641001e6830
(System.IO.Stream xcf18e5243f8d5fd3, System.String xafe2f3653ee64ebc,
Aspose.Words.Saving.SaveOptions xc27f01f21f67608c) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, Aspose.Words.Saving.SaveOptions saveOptions) [0x00000] in
:0 at Aspose.Words.Document.Save (System.String
fileName, SaveFormat saveFormat) [0x00000] in :0
at MonoTest.MainClass.Main (System.String[] args) [0x00000] in
:0
Any advice is appreciated. Thanks.
Often inner exceptions is a very common problem for converting words documents in PDF via Aspose.
It can be due to some reasones like:
2013 MS Word office.
Some complex elements in word
Old version of Aspose.Words.dll.
Solutions:
Try to update Aspose.Words.dll to new version. If it's still not working - write to aspose forum, and this error will be fixed in new release.
Check word document itself. may be you can find something thac call this inner exception, than try to remove it and check again. If this is acceptable of course.

MonoDroid ObjectDisposedException when loading XDocument for RSS

I'm fiddling with MonoDroid (aka Mono for Android) trying to build a simple podcast downloading app, currently just testing out retrieval of an RSS feed contents.
My simple app is:
an edit text where the url for an RSS feed is input
a button to 'download' the rss
a text display for the output of the download operation
When a user clicks on download, I fetch the RSS contents, currently using XDocument (I also tried with just WebRequest / Streams etc.), here's the short version:
void button_Click(object sender, EventArgs e)
{
output.Text += "user input: " + rssUriInput.Text + "\n";
try
{
output.Text += "### document ###";
output.Text += XDocument.Load(rssUriInput.Text).ToString();
output.Text += "### document ###";
}
catch (Exception ex)
{
output.Text += "OOOPS something went wrong:\n" + ex.ToString();
}
}
I've tried several approaches, but keep getting ObjectDisposedExceptions when I do XDocument.Load(/*my uri here*/);
My AssemblyInfo.cs includes the
[assembly: UsesPermission(Android.Manifest.Permission.Internet)]
Now, disclaimer, after getting hello world running I kind of went off on my own, so I may be missing some MonoDroid fundamentals, but this code works in a normal C# app (I tested it) but
Why am I doing wrong here? Do I have to do something special to use xml / linq / network access in MonoDroid?
here is the full activity code:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Xml.Linq;
namespace RssDownlowd
{
[Activity(Label = "RssDownlowd", MainLauncher = true, Icon = "#drawable/icon")]
public class Activity1 : Activity
{
EditText rssUriInput;
Button button;
TextView output;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.RssDownload);
rssUriInput = FindViewById<EditText>(Resource.Id.rssUriText);
button = FindViewById<Button>(Resource.Id.downloadButton);
output = FindViewById<TextView>(Resource.Id.outputTextView);
button.Click += new EventHandler(button_Click);
}
void button_Click(object sender, EventArgs e)
{
output.Text += "user input: " + rssUriInput.Text + "\n";
try
{
output.Text += "### document ###";
output.Text += XDocument.Load(rssUriInput.Text).ToString();
output.Text += "### document ###";
}
catch (Exception ex)
{
output.Text += "OOOPS something went wrong:\n" + ex.ToString();
}
}
}
}
And here is the full exception:
"System.ObjectDisposedException: The object was used after being disposed.
at System.Net.WebConnection.BeginRead (System.Net.HttpWebRequest request, System.Byte[] buffer, Int32 offset, Int32 size, System.AsyncCallback cb, System.Object state) [0x00000] in <filename unknown>:0
at System.Net.WebConnectionStream.BeginRead (System.Byte[] buffer, Int32 offset, Int32 size, System.AsyncCallback cb, System.Object state) [0x00000] in <filename unknown>:0
at System.Net.WebConnectionStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0
at System.Xml.XmlInputStream.Read (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0
at System.Xml.NonBlockingStreamReader.ReadBuffer () [0x00000] in <filename unknown>:0
at System.Xml.NonBlockingStreamReader.Read (System.Char[] dest_buffer, Int32 index, Int32 count) [0x00000] in <filename unknown>:0
at System.Xml.XmlStreamReader.Read (System.Char[] dest_buffer, Int32 index, Int32 count) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.ReadTextReader (Int32 remained) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.PeekChar () [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.ReadChar () [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.Expect (Int32 expected) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.ReadEntityReference (Boolean ignoreEntityReferences) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.ReadReference (Boolean ignoreEntityReferences) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.ReadText (Boolean notWhitespace) [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.ReadContent () [0x00000] in <filename unknown>:0
at Mono.Xml2.XmlTextReader.Read () [0x00000] in <filename unknown>:0
at System.Xml.XmlTextReader.Read () [0x00000] in <filename unknown>:0
at Mono.Xml.XmlFilterReader.Read () [0x00000] in <filename unknown>:0
at System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XElement.LoadCore (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XNode.ReadFrom (System.Xml.XmlReader r, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XContainer.ReadContentFrom (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.ReadContent (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.LoadCore (System.Xml.XmlReader reader, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri, LoadOptions options) [0x00000] in <filename unknown>:0
at System.Xml.Linq.XDocument.Load (System.String uri) [0x00000] in <filename unknown>:0
at RssDownlowd.Activity1.button_Click (System.Object sender, System.EventArgs e) [0x0004a] in C:\\Users\\khd483\\code\\HelloMonoDroid\\RssDownlowd\\Activity1.cs:47 "
Strangely enough when I tried your code it worked just fine:
Have you enabled Linking in your project in the Mono for Android options?
Also consider doing an async download of the RSS as it blocks the UI Thread until it is done, making the app unresponsive.

Categories