Perhaps the browser control doesn't have its Document property set, in which case it will throw a NullReferenceException. You can use the DocumentText property to build the HTML manually. This is easier than working the DOM object model.
| |
StringBuilder builder = new StringBuilder(); builder.Append( "<html>"); builder.Append( "<title>Help not installed.</title>"); builder.Append( "<body>"); builder.Append( "There is no help available."); builder.Append( "</body>"); builder.Append( "</html>"); webBrowser1.DocumentText = builder.ToString(); HtmlDocument htmlDoc = webBrowser1.Document; |
Another, better, option is to distribute a "No help available" html page with your application, and load this when there is no help setting:
| |
webBrowser1.DocumentStream = File.Open(@"..\..\HelpNotInstalled.htm", FileMode.Open, FileAccess.Read);
|