This project has moved and is read-only. For the latest updates, please go here.

Problem using Html Agility Pack in Mono

Topics: User Forum
Sep 26, 2007 at 10:34 AM
Edited Sep 26, 2007 at 10:38 AM
Hi all,

I am trying to divide a given web page into tiltle, text and urls. I am planning to use htmlagilitypack for this. But when I run this code in mono. I am ending up with a runtime error which i cannot figure out.

this is the code I am using

using System;
using HtmlAgilityPack;

namespace parsehtml {
public class parsehtml {
public static void Main() {
HtmlWeb htmlWeb = new HtmlWeb();
HtmlDocument doc = htmlWeb.Load("");

I compile it with mcs parsehtml.cs -r:HtmlAgilityPack.dll

When I run the code I get this error

Unhandled Exception: System.ObjectDisposedException: The object was used after being disposed.
at System.Net.HttpWebResponse.CheckDisposed () 0x00000
at System.Net.HttpWebResponse.get_StatusCode () 0x00000
at (wrapper remoting-invoke-with-check) System.Net.HttpWebResponse:get_StatusCode ()
at HtmlAgilityPack.HtmlWeb.Get (System.Uri uri, System.String method, System.String path, HtmlAgilityPack.HtmlDocument doc) 0x00000
at HtmlAgilityPack.HtmlWeb.LoadUrl (System.Uri uri, System.String method) 0x00000
at HtmlAgilityPack.HtmlWeb.Load (System.String url, System.String method) 0x00000
at HtmlAgilityPack.HtmlWeb.Load (System.String url) 0x00000
at parsehtml.parsehtml.Main () 0x00000

I am new to both C# and html agility pack, so if I being really dense here please bear with me.

Thanks for the help.
Nov 17, 2007 at 6:06 PM
Well, for my concern, I am quite new to Mono :-)
That is strange. Have you tried to used the existing Binaries? That should work as is as far as understand Mono, and IL concepts.
It means HttpWebResponse is implemented differently on Mono vs the Windows CLR. Strange. Have you tried asking the Mono guys?