I'm struggling with the browser control in my WEC7 application. I'm trying to display a local file in the webBrowser control, and everything appears to be working except that the page does not show up in the control on my form. All I see is a white rectangle where the webBrowser control is.
I made a stand-alone test app which does nothing but load a local file into the webBrowser control. I found code elsewhere on stackoverflow which seemed pretty clear. This is the code that loads the page:
private void LoadPageBtn_Click(object sender, EventArgs e)
{
try
{
string applicationDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetNam‌e().CodeBase);
string myFile = Path.Combine(applicationDirectory, @"HTMLPage1.htm");
Uri uri = new Uri(myFile);
webBrowser1.Navigate(uri);
}
catch (Exception ex)
{
Debug.WriteLine("ERROR: " + ex.Message);
}
}
The file HTMLPage1.htm is really basic and shows up fine in any desktop browser. If I provide a bogus file name in the code then I get a file not found exception, so I'm pretty sure the file is being deployed correctly on the target (set to "always copy" in the file properties).
I catch the Navigating, Navigated, and Complete events from the webBrowser control and output some debug stuff, including the URL from the WebBrowserNavigatingEventArgs. When the code runs I get the following debug output:
Navigating: file:///Program Files/webtest/HTMLPage1.htm
Complete:
I never see the Navigated event but I'm not sure that's a problem.
And the darn webBrowser control continued to show a white rectangle. Can anyone suggest what I may be missing?
I have posted the code here in case anyone would be kind enough to try it out themselves: https://drive.google.com/file/d/0B75fBmfP8FI4YmpvYXFXcGN1Qzg/view?usp=sharing