1

When running the following to create an instance of HtmlDocument an object not matched exception is thrown on the last line

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);

request.Method = "GET";
request.Timeout = 5000;//stop trying after 5s

WebResponse response = request.GetResponse();

HtmlDocument doc = new HtmlDocument();
doc.OptionReadEncoding = false;
doc.Load(response.GetResponseStream());

The exception thrown comes up as " Object of type 'NInterpret.InterpretedObject' doesnt't match target type 'System.Collections.Generic.IEnumerable'1[NInterpretedObject]' "

The same error gets thrown trying to load html from a string, for example:

HtmlDocument doc = new HtmlDocument();
doc.OptionReadEncoding = false;
doc.LoadHtml("<html><head><title>a page</title></head><body>some content</body></html>");

This only happens when running the app through the Xamarin Live Player app, not if the app is compiled an an APK and installed directly on to the device then run.

RobertEves92
  • 145
  • 12
  • I have the same problem, see this: https://github.com/zzzprojects/html-agility-pack/issues/186 – Jannik May 01 '18 at 19:34

1 Answers1

0

This appears to be an issue with Xamarin Live Player, rather than the code itself.

Running the code directly on a device without the use of Xamarin Live Player works perfectly.

RobertEves92
  • 145
  • 12