After scratching my head some over the various responses the application gave me during debugging and then googling some on the internets I finally came up with this solution that works
without a form to host your webbrowser control. Since I'm not used to writing programs in VB.NET I'll give you my work in C#. If you have any difficulties translating it into VB.net maybe you'll find some assistance here on CP. Anyhow trying it out in C# should not pose a problem. So many words, here is the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WebBrowserWithoutAForm
{
class Program
{
private static bool completed = false;
private static WebBrowser wb;
[STAThread]
static void Main(string[] args)
{
wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
wb.Navigate("http://www.google.com");
while (!completed)
{
Application.DoEvents();
Thread.Sleep(100);
}
Console.Write("\n\nDone with it!\n\n");
Console.ReadLine();
}
static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
Console.WriteLine(wb.Document.Body.InnerHtml);
completed = true;
}
}
}
I know I may receive some bashing over using Application.DoEvents() but it still works though and fullfills your request of not wanting to use a form as a container. System.Windows.Forms still has to be included though as that is where the WebBrowser control lives.
Hint: The STAThread attribute of procedure main is essential when initializing the WebBroswer control as this is not allowed in Multi-Threaded Appartment Mode.
[Edit]There may be some other way than using Application.DoEvents() which would involve implementing and setting up one's own message pump. As time allows I will look into this and report on my findings
[/Edit]
Happy coding and have fun!
-MRB