I have an Add-in with ToolWindow (TW). The ToolWindow is a WindowFormControlLibrary (UC). On the UserControl there's a WebBrowser control (WB)
When AddIn is loaded, it initializes the ToolWindow, which means UserControl's InitializeComponent() event is called. I can call another event doNavigate(). And it navigates to the URL. and SHOW it in the WebBrowser control.
However, in the Add-in's Exec
event, when I try to call the doNavigate() event. It load or at least does something, however, it does NOT display the page in the control.
/*This file is UC.cs in WindowsFormControlLibrary Project */
//Event is lanuched when the Add-in and tool window are loaded
public UC()
{
InitializeComponent();
doNavigate("www.google.com");
}
public void doNavigaet(string url)
{
WB.Navigate(url);
while (wBrowser.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
}
This is how I am calling the doNavigate()
event from the Exec
event of the Add-in
/*This file is Connect.cs in the Addins Project.*/
public void Exec(string CmdName, vsCommandExecOption ExecuteOption, ref object VariantIn, ref object VariantOut, ref bool Handled)
{
UC uc = new UC();
UC.doNavigate("www.bing.com");
Handled = true;
return;
}
There's NO error, only the page (Bing) is not displayed in the web browser.
In the output window, I get: The thread '<No Name>' (0x502c) has exited with code 0 (0x0).
Could anyone please help me what could be the reason?
Thanks very much.