vb.net - Problem remaking com object after program has closed

Have been searching for a solution to this problem for days with no luck so I decided to post here and hope someone can help me. What makes it even harder is that I can't replicate this problem on my computer very consistently. Sometimes I will get the error but most of the time I won't.

Basically what is happening is I am creating an IE object which my program then controls for a long period of time. What is happening is, if a user exits the program it calls oIE.Quit() then closes the program. This should close internet explorer and all processes associated with it.

But, the iexplorer process doesn't end up closing. Then when the user tries to run the program again we get this error "System.Runtime.InteropServices.COMException (0x80004005): Creating an instance of the COM component with CLSID {0002DF01-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80004005.".

To fix this we simply close the any iexplorer.exe processes that are open and it will let us create our ie object again. This happens also if the program crashes and they try to restart it.

I am not sure what is causing this or if I am missing something that has to do with com objects. But I am simply stuck.

Here is some code although plugging in this code likely won't reproduce any errors:

'create ie object
oIE = New SHDocVw.InternetExplorer
oIE.Visible = False
oIE.Silent = True

'kill ie object


The exception you get is hopeless, that's E_FAIL, "Unspecified error". There isn't any obvious reason why this would fail, starting another instance of IE when your program starts back up shouldn't be a problem. Well, short from those ghost instances of IE that keep running forever. I would guess that you got this exception for the same reason that IE didn't quit when you called Quit() the last time.

Do consider the kind of mishap you'll create when your program aborts and doesn't get around to cleanly shutting down IE. Using Environment.Exit() would be quite unhealthy for example. Or any other kind of nasty kaboom that doesn't let the finalizer thread run at termination. Maybe that has already happened many times before, now IE just refuses to create any more instances? How many instances do you have to kill when you need to get it going again?

The much better mousetrap here is to run IE in-process in your own program rather than out-of-process with SHDocVw. So that when your program terminates, it takes IE with it. It is also much more efficient, there's a lot of overhead involved in making out-of-process COM server calls.

You do this by using WebBrowser in your program.

Need Your Help

Selecting row based on ID and then again based on cardinality of text box

php mysql sql laravel eloquent

My issue is I need to rank and group the following database like this Film -> Most used text.

NSBitmapImageRep to NSMutableArray or NSMutableDictionary

objective-c opengl nsmutablearray nsmutabledictionary nsbitmapimagerep

Is it possible to store NSBitmapImageRep copy to NSMutableDictionary or NSMutableArray? I need to save copy of OpenGL texture somewhere so, that I could use it later. So if I would do glReadPixels,...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.