I was trying to write a program that opened an instance of Internet Explorer in a separate window, rather than use the Browser control that comes with the .NET platform.
Unfortunately, it proved almost impossible to find any references to the interfaces necessary to do the job.
This is a very simple program that allows the user to type a URL into a textbox, and then open IE directly to that URL.
This only works with IE4 and above.
The heart of the code is exposing the IWebBrowserApp interface. This interface is located in the SHDocVw.dll, which can be found (on Win2K/Xp) in the System32 directory.
The source code is simple:
using SHDocVw;
public void OpenBrowser(string url)
{
object o = null;
SHDocVw.InternetExplorer ie = new
SHDocVw.InternetExplorerClass();
IWebBrowserApp wb = (IWebBrowserApp) ie;
wb.Visible = true;
//Do anything else with the window here that you wish
wb.Navigate(url, ref o, ref o, ref o, ref o);
}
I hope this is useful to others.
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Prakash JayaniPosted Jun 3, 2015, 7:43 AM
I have used the code mentioned above to open Report in Report builder 3.0 i.e url = http://<server>/<site>/reportserver/reportbuilder/ReportBuilder_3_0_0_0.application?ReportPath=<path to my report>; it is working fine in win7 and 8 with IE10 where IE window opens for a second which navigates to given report URL then it starts loading report in report builer 3.0 and IE tab automatically closes. but it is not working in win 8.1 with IE11 where report is opening successfully but a blank IE ta remain open in background, can you suggest any solution for that other then wb.Quit()
Parthesh MehtaPosted Dec 16, 2010, 4:56 AM
Hi, great article. If i uninstall ie from os then it is work?
MartinPosted Jul 1, 2010, 11:11 AM
Hello! Nice solution, but how can I make the instance of IE I've connected to, to print the page?
Tom JacksoneditedPosted Feb 21, 2010, 9:26 PMEdited Feb 21, 2010, 9:31 PM
I had those pesky "Retrieving the COM class factory for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed due to the following error: 80070005." errors, too, but found it was due to Impersonation I was doing during that part of the code. I did a wic.Undo() before that section and then it worked fine. I should note that, when running this, it has to be done with the account that has access to the DCOM activation, access, and launch permissions of "Internet Explorer (ver. 1.0)" and be logged in with that account (no impersonation). Even if you put in another account, giving it those rights to locally or remotely activate IE (depending on if this is local code or will go on another server), and that account is an Admin on the computer that will be tapping into IE, you still apparently have to be logged-in with that account for it to work. I don't get it, either, but at least I know why the errors occurred. Here's my code (applicable section): InternetExplorer ieExplorer = null; // Create an instance of IE ieExplorer = new InternetExplorerClass(); IWebBrowser2 webDocument = (IWebBrowser2)ieExplorer; object missing = System.Reflection.Missing.Value; string url = "http://www.google.com"; webDocument.Navigate(url, ref missing, ref missing, ref missing, ref missing); webDocument.Visible = true; // do whatever you want with webDocument... -Tom
cagri gunduzPosted Oct 18, 2009, 1:17 PM
when i used the your code i get a this error message from IClassFactory (-0000-0000-C000-000000000046) 0002DF01 with CLSID of the COM component instance creation process failed with the following error: 80004005. can anyone help me how can i pass this error ?
as seditedPosted May 19, 2009, 5:58 AMEdited May 19, 2009, 6:00 AM
System.Diagnostics.Process.Start("IEXPLORE.EXE", "www.pannone.co.uk"); Gabriel Renom
PrasannaPosted Nov 14, 2008, 2:49 AM
Thanks Gregory for this code. Great help.You saved my life :-)
hemal soniPosted Mar 11, 2008, 3:17 AM
Hi, when i create the object SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass(); in web application i m getting below error Retrieving the COM class factory for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed due to the following error: 80070005. i have include Microsoft HTML Object Library : c:\windows\system32\MSHTML.tlb Microsoft Internet Controls : c:\windows\system32\ieframe.dll both the dlls but still not able to create the object please help me on this it is really very urgent for me
kami dufferPosted Mar 6, 2008, 3:27 AM
nice solution man