views:

25

answers:

1

I'm porting a VS Add-in to VS 2010 from VS 2008 and need to be able to open the built-in web browser.

In VS 2008, it was possible to get a handle on the web browser window with code like this:

var win = _applicationObject.Windows.Item(Constants.vsWindowKindWebBrowser);

However, the same code does not work in VS 2010 when an instance of the web browser has not already been opened. Instead it gives an ArgumentException on the Item index.

A: 

This appears to work:

_applicationObject.ItemOperations.Navigate("about:blank", vsNavigateOptions.vsNavigateOptionsDefault);

This code opens the specified file in the browse window whether it's already opened or not. And then it's possible to grab a reference to the window object and wire up events such as BeforeNavigate2.

Catch22

related questions