WebClient: (System.Net.WebException) Error getting response stream (ReadDone1): ReceiveFailure - c#

This is a MonoTouch application. I see errors out in the field with this exception. I see other SO quesitons, but nothing seems to be solving my issue. Could this be related to maxRequestLength on the server, or executionTimeout? I really have NO ideas...
I am not using a WebRequest, i'm using a WebClient. Please Help!
STACK TRACE
System.Net.WebException: Error getting response stream (ReadDone1): ReceiveFailure
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in <filename unknown>:0
at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in <filename unknown>:0
at System.Net.WebClient.UploadFileCore (System.Uri address, System.String method, System.String fileName, System.Object userToken) [0x00000] in <filename unknown>:0
at System.Net.WebClient.UploadFile (System.Uri address, System.String method, System.String fileName) [0x00000] in <filename unknown>:0
Client Code (Monotouch)
public void UploadVideo(Guid organizationId, string path) {
WebClient wc = new WebClient();
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password)));
var authHeader = string.Format("Basic {0}", token);
wc.Headers.Add("Authorization", authHeader);
var resource = string.Format("/organizations/{0}/SyncVideo/", organizationId);
var fi = new FileInfo(path);
wc.UploadFile(restClient.BaseUrl + resource, "POST", path);
wc.Dispose();
}
Server Code (ASP.Net MVC3)
[HttpPost, Url("v3/organizations/{organizationId?}/SyncVideo/")]
public virtual JsonResult SyncVideo(HttpPostedFileBase file, Guid? organizationId) {
if (organizationId.IsNull()) throw new HttpNotFoundExecption();
if (organizationId != RESTContext.OrganizationId) throw new HttpNotAuthorizedException();
var basePath = RESTContext.Config.VideoPath;
using (new Impersonator(RESTContext.Config.VideoPathUsername, RESTContext.Config.VideoPathDomain,
RESTContext.Config.VideoPathPassword)) {
if (!Directory.Exists(basePath))
Directory.CreateDirectory(basePath);
file.SaveAs(basePath + #"\" + file.FileName);
}
return JsonSuccess();
}

Related

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?

How to I catch SSL exceptions in a Mono HTTPListener server?

I'm trying to add HTTPS support to my simple Mono HTTP server. It works perfectly most of the time, but the application crashes when an SSL exception occurs, such as the client canceling the handshake. Obviously something like that shouldn't completely crash it, so I need to catch that exception somehow.
Code:
static void Main(string[] args)
{
try
{
var listener = new HttpListener();
string prefix = "https://*:8443/";
listener.Prefixes.Add(prefix);
Console.WriteLine("Starting HTTP server at " + prefix);
listener.Start();
while (true)
{
try
{
var context = listener.GetContext();
Console.WriteLine(context.Request.Url);
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Exception processing request: " + e);
Console.ResetColor();
}
}
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Exception caught! " + e);
}
}
Here's the log when I get a wonky client trying to connect:
Starting HTTP server at https://*:8443/
Unhandled Exception:
System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The client stopped the handshake.
at Mono.Security.Protocol.Tls.SslServerStream.EndNegotiateHandshake (IAsyncResult asyncResult) <0x41e581b0 + 0x0022b> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x41e57d20 + 0x00086> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) <0x41e50110 + 0x0015f> in <filename unknown>:0
at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsServer (IAsyncResult asyncResult) <0x41e50000 + 0x0003e> in <filename unknown>:0
at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsServer (System.Security.Cryptography.X509Certificates.X509Certificate serverCertificate, Boolean clientCertificateRequired, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) <0x41e40990 + 0x00055> in <filename unknown>:0
at System.Net.HttpConnection.Init () <0x41e3e0e0 + 0x0005f> in <filename unknown>:0
at System.Net.HttpConnection..ctor (System.Net.Sockets.Socket sock, System.Net.EndPointListener epl, Boolean secure, System.Security.Cryptography.X509Certificates.X509Certificate cert) <0x41e3b670 + 0x003e7> in <filename unknown>:0
at System.Net.EndPointListener.OnAccept (System.Object sender, System.EventArgs e) <0x41e3b210 + 0x002a7> in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) <0x41e3b1d0 + 0x0002e> in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.Complete () <0x41e3b1b0 + 0x00013> in <filename unknown>:0
at System.Net.Sockets.Socket.<AcceptAsyncCallback>m__0 (IAsyncResult ares) <0x41e3aa70 + 0x0037f> in <filename unknown>:0
at System.Net.Sockets.SocketAsyncResult+<Complete>c__AnonStorey0.<>m__0 (System.Object _) <0x41e3a980 + 0x0001d> in <filename unknown>:0
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x7f22cac25460 + 0x0002f> in <filename unknown>:0
at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x7f22cac239e0 + 0x001d6> in <filename unknown>:0
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x7f22cac252e0 + 0x00008> in <filename unknown>:0
Not quite a solution, but I was able to work around the problem by creating a local reverse proxy with nginx, and setting the mono server to only listen on 127.0.0.1
https://www.nginx.com/resources/admin-guide/reverse-proxy/

Can't send email on Ubuntu server

I'm having an issue with my little app. App is able to send an email when it's running on Windows, but not when it's on Ubuntu 15.10.
C# code:
public bool sendMail(string subject, string msg, string[] emailTo)
{
MailMessage mail = new MailMessage();
SmtpClient client = new SmtpClient();
MailAddress from = new MailAddress("noreply#someserver.com", "Someserver - No Reply");
// client settings
client.EnableSsl = true;
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("noreply#someserver.com", "someserverPassword");
client.Host = "smtp.office365.com";
//main settings
mail.IsBodyHtml = true;
mail.Body = msg + footer;
mail.Subject = subject;
mail.From = from;
foreach (string mailTo in emailTo)
{
mail.To.Add(mailTo);
}
client.Send(mail);
return true;
}
and here is the error i get:
Unhandled Exception:
System.Net.Mail.SmtpException: Message could not be sent. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.InvalidOperationException: SSL authentication error: RemoteCertificateNotAvailable
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) <0x41d12100 + 0x000ff> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) <0x41d12040 + 0x0002b> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) <0x41cf64c0 + 0x00213> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) <0x41d12d70 + 0x000bf> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x41d12b10 + 0x0007f> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) <0x41cf4090 + 0x00153> in <filename unknown>:0
at System.Net.Security.SslStream.EndAuthenticateAsClient (IAsyncResult asyncResult) <0x41cf3ec0 + 0x0003e> in <filename unknown>:0
at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) <0x41ced140 + 0x00055> in <filename unknown>:0
at System.Net.Mail.SmtpClient.InitiateSecureConnection () <0x41cecc70 + 0x000df> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) <0x41cea260 + 0x0020f> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) <0x41ce3120 + 0x00207> in <filename unknown>:0
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x00113> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x001c7> in <filename unknown>:0
at Chillblast_ERP.MailingSystem.sendMail (System.String subject, System.String msg, System.String[] emailTo) <0x41cc8c80 + 0x00273> in <filename unknown>:0
at erptesting.Program.Main (System.String[] args) <0x41c72800 + 0x001f3> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.Mail.SmtpException: Message could not be sent. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> System.InvalidOperationException: SSL authentication error: RemoteCertificateNotAvailable
at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) <0x41d12100 + 0x000ff> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) <0x41d12040 + 0x0002b> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) <0x41cf64c0 + 0x00213> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (IAsyncResult result) <0x41d12d70 + 0x000bf> in <filename unknown>:0
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) <0x41d12b10 + 0x0007f> in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (IAsyncResult asyncResult) <0x41cf4090 + 0x00153> in <filename unknown>:0
at System.Net.Security.SslStream.EndAuthenticateAsClient (IAsyncResult asyncResult) <0x41cf3ec0 + 0x0003e> in <filename unknown>:0
at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation) <0x41ced140 + 0x00055> in <filename unknown>:0
at System.Net.Mail.SmtpClient.InitiateSecureConnection () <0x41cecc70 + 0x000df> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendCore (System.Net.Mail.MailMessage message) <0x41cea260 + 0x0020f> in <filename unknown>:0
at System.Net.Mail.SmtpClient.SendInternal (System.Net.Mail.MailMessage message) <0x41ce3120 + 0x00207> in <filename unknown>:0
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x00113> in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send (System.Net.Mail.MailMessage message) <0x41ce2d90 + 0x001c7> in <filename unknown>:0
at Chillblast_ERP.MailingSystem.sendMail (System.String subject, System.String msg, System.String[] emailTo) <0x41cc8c80 + 0x00273> in <filename unknown>:0
at erptesting.Program.Main (System.String[] args) <0x41c72800 + 0x001f3> in <filename unknown>:0
Found necessary certificates:
sudo certmgr -ssl -m https://go.microsoft.com
sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
sudo certmgr -ssl -m https://nuget.org
mozroots –-import -–sync

Mono on Ubuntu MySqlConnection.Open resulting in System.OverflowException

I am trying to get the demo from http://www.mono-project.com/MySQL working on Ubuntu 11.10, using Mono 2.10.5.
Installed MySQL v2 drivers (after renaming) to the gac. Added provider a line to the machine.config.
Hello World demo compiles and runs fine. The following code executes and connects on MSVS fine.
The compile cmd works: mcs TestMysqlConnect.cs -r:System.Data.dll -r:/home/steve/MONO/Assemblies/Mysql/v2/MySql.Data.dll
using System;
using System.Data;
using MySql.Data.MySqlClient;
public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=192.168.111.4;" +
"Database=LOADTRACKER;" +
"Port=3306;" +
"User ID=oec;" +
"Password=oec;" +
"Pooling=false";
Console.WriteLine("Create MySqlConnection");
IDbConnection dbcon;
dbcon = new MySqlConnection(connectionString);
Console.WriteLine("dbcon.Open();");
dbcon.Open();
IDbCommand dbcmd = dbcon.CreateCommand();
Console.WriteLine("dbcon.CreateCommand();");
// requires a table to be created named employee
// with columns firstname and lastname
// such as,
// CREATE TABLE employee (
// firstname varchar(32),
// lastname varchar(32));
string sql =
"SELECT Account, Security " +
"FROM accesslist";
dbcmd.CommandText = sql;
IDataReader reader = dbcmd.ExecuteReader();
while(reader.Read()) {
string acct = (string) reader["Account"];
string sec = (string) reader["Security"];
Console.WriteLine("Acct: " + acct + " (" + sec + ")");
}
// clean up
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
dbcon.Close();
dbcon = null;
}
}
Executing this code produces:
$mono ./TestMysqlConnect.exe
Create MySqlConnection
dbcon.Open();
Unhandled Exception: System.OverflowException: Number overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.HandleAuthChange (MySql.Data.MySqlClient.MySqlPacket packet) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.OverflowException: Number overflow.
at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.HandleAuthChange (MySql.Data.MySqlClient.MySqlPacket packet) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, Boolean reset) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0
Interestingly, if I provide a bad user/password, I get the expected exception of:
[ERROR] FATAL UNHANDLED EXCEPTION: MySql.Data.MySqlClient.MySqlException: Authentication to host '192.168.111.4' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'#'linux' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException: Access denied for user 'root'#'linux' (using password: YES)
Any help is greatly appreciated. Thank you.

Processing Linq XML string

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

Categories