System.InvalidCastException : QueryInterface for interface Microsoft.ShDocVw.IWebBrowser2 failed



Guys,

I'm getting this exception with the stack trace

1)
Tranmit.Sprinter.WebApp.Testing.Purchasing.Invoicing.Edit.EditInvoiceTest.EditInvoice_H_2
: System.InvalidCastException : QueryInterface for interface
Microsoft.ShDocVw.IWebBrowser2 failed.
at Microsoft.ShDocVw.InternetExplorerClass.Quit()
at Tranmit.Testing.InternetExplorerWrapper.Dispose(Boolean
disposeManagedComponents)
at Tranmit.Testing.InternetExplorerWrapper.Dispose()
at
Tranmit.Sprinter.WebApp.Testing.Purchasing.Invoicing.Edit.EditInvoiceTest.EditInvoice_H_2()

Which is thrown from code such as this

if( ! this.disposed )
{
if(disposeManagedComponents)
{
ClearNewIeWindows();

if(InternetExplorer != null)
{
if(
Convert.ToBoolean(ConfigurationSettings.AppSettings["WebBrowserQuitOnDispose"])
==
true)
{
InternetExplorer.Quit();
}
}
}

// Release unmanaged resources. If disposing is false,
if(internetExplorer != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(internetExplorer);
}
}

disposed = true;
}

In the dispose implementation of a wrapper IE class which simply wraps calls
to the InternetExplorer object which is of type

/// <summary>
/// IE object managed by this class
/// </summary>
private InternetExplorer internetExplorer = new
Microsoft.ShDocVw.InternetExplorerClass();

Any ideas why I should get this randomly?



.


Loading