I have this exception thrown out when I execute the following:
InternetExplorer browser = new InternetExplorerClass();
mshtml.IHTMLDocument2 doc2 = (IHTMLDocument2)browser .Document ;
if (doc2 != null)
{
IHTMLWindow2 win = doc2.parentWindow;
win.execScript("alert('hello')", "javascript");
}