svick/LINQ-to-Wiki

XmlException on var w = new Wiki(...)

MarcBra opened this issue · 2 comments

Hello,

I get an exception when calling the constructor of the Wiki class on wikipedia. The code worked fine a couple of months ago and hasn't been changed since. Can you give me a hint on what's going on? Thank you very much for your great work!!

Marc

var wiki = new Wiki("...", "en.wikipedia.org");

Throws a XmlException:

"'en' is an unexpected token. The expected token is '"' or '''. Line 2, position 12."

at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at LinqToWiki.Download.Downloader.Download(IEnumerable1 parameters) in c:\code\LinqToWiki\LinqToWiki.Core\Download\Downloader.cs:line 74 at LinqToWiki.Internals.QueryProcessor.Download(WikiInfo wiki, IEnumerable1 processedParameters, IEnumerable1 queryContinues) in c:\code\LinqToWiki\LinqToWiki.Core\Internals\QueryProcessor.cs:line 156 at LinqToWiki.Internals.QueryProcessor1.ExecuteSingle[TResult](QueryParameters2 parameters) in c:\code\LinqToWiki\LinqToWiki.Core\Internals\QueryProcessor.cs:line 76 at LinqToWiki.Internals.NamespaceInfo.GetNamespaces(WikiInfo wiki) in c:\code\LinqToWiki\LinqToWiki.Core\Internals\NamespaceInfo.cs:line 38 at LinqToWiki.Internals.WikiInfo..ctor(String userAgent, String baseUrl, String apiPath, IEnumerable1 namespaces) in c:\code\LinqToWiki\LinqToWiki.Core\Internals\WikiInfo.cs:line 70
at LinqToWiki.Generated.Wiki..ctor(String userAgent, String baseUri, String apiPath) in c:\Users\Svick\AppData\Local\Temp\LinqToWiki\Wiki.cs:line 32

Same exception upon running the sample application.

System.Xml.XmlException occurred HResult=0x80131940 Message='en' is an unexpected token. The expected token is '"' or '''. Line 2, position 12. Source=System.Xml

After little bit of try & error approach, I was able to fix the issue. Correct way to get connected is as below.

var wiki = new Wiki("LinqToWiki.Samples", "https://en.wikipedia.org", "https://en.wikipedia.org/w/api.php");