Problem with WebBrowser2 based class


I have built a class to make the WebBrowser2 and accompanying objects a bit easier to use.  Basically I have handled all the bstr conversion operations necessary to open, close, navigate and so forth inside of class functions so that all operations can be done without having to go through the mess associated.  I have a second class that stores the document elements broken down into dropdowns, textboxes and so forth so that interacting with the document like entering text, selecting options and clicking buttons and hyperlinks can all be a simple one-liner.  I have had one problem from the beginning.  After having navigated with the browser there are always several:

First-chance exception in SuperManager.exe (KERNEL32.DLL): 0x80010108: (no name).

that come up when I close the browser.  After quitting the debugger I get an object dump.  The place of allocation is never given and I have checked and rechecked and it seems that none of my internally allocated stuff gets left over.  The contents of the dump usually contain urls, textbox names, hyperlink texts and so forth.   Any ideas what could be causing this?  I will include the following example function for you to look over and see if I leave the potential of having something left allocated.

int WebDocument::ClickHyperlink(const char *label)
      int i;
      BSTR bstr;

      char *string;

      HRESULT hr=0;

      for (i=0; i<nHyperlinks; i++)      {
            hr = pHyperlink[i]->get_innerText(&bstr);
            if(hr!=S_OK) return 1000;

            if(bstr==NULL) continue;

            string = ConvertBSTRToString(bstr);
            if(strcmp(string, label)==0)            {
                  hr = pHyperlink[i]->click();
                  if(hr!=S_OK) return 1001;

            delete[] string;
      if(i==nHyperlinks+1) return 1002; //Not found
      return 1;

The others follow a similar format.

This problem just means I have a memory leak.  The second problem is more limiting.  I have started using these classes inside worker threads.  I have a pBrowser object attached to theApp and I use it throughout the application when I need to interact with the web.  I have had no problem with sharing an open browser inside the main application thread, but after using it once in a worker thread it is rendered useless.  When the thread closes I get again a bunch of:

First-chance exception in SuperManager.exe (KERNEL32.DLL): 0x80010108: (no name).

When I try to navigate again I get:

First-chance exception in SuperManager.exe (KERNEL32.DLL): 0x800401FD: (no name).
First-chance exception in SuperManager.exe (KERNEL32.DLL): 0xE06D7363: Microsoft C++ Exception.

One of them is probably thrown by me and used to handle the error.

Any ideas?  Are the two problems connected?

Thanks. David
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>Any ideas?  Are the two problems connected?

If it is only a First-chance exception, you may safely ignore that. See;en-us;105675 ("105675 - INFO: First and Second Chance Exception Handling")
david_johnsAuthor Commented:

Thanks for the insight.  I was not so much worried about the exceptions as I was about the memory dumps, and I guess I assumed that they were connected to each other.  Perhaps that is not really the case.  Any ideas from anyone about the leaks or the reason using it by another thread makes the browser unavailable for future use?

Thanks. David
david_johnsAuthor Commented:
I was able to find the memory leaks.  They were afterall my mistake.  I still have the same problem with trying to re-use the open browser, however, after running it from a seperate thread.  Are the com pointers somehow not threadsafe?

Thanks. David
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

>>Are the com pointers somehow not threadsafe?

That depends on the COM object they are pointing to - see;en-us;150777 ("INFO: Descriptions and Workings of OLE Threading Models")

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
david_johnsAuthor Commented:

Sorry for the lack of feedback.  I was hoping for a more comprehensive answer like the one you gave in the sequil to this thread:

Thanks for you help.

Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.