Problem with WebBrowser2 based class

Posted on 2003-10-28
Medium Priority
Last Modified: 2007-12-19

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
Question by:david_johns
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 86

Expert Comment

ID: 9637325
>>Any ideas?  Are the two problems connected?

If it is only a First-chance exception, you may safely ignore that. See http://support.microsoft.com/default.aspx?scid=kb;en-us;105675 ("105675 - INFO: First and Second Chance Exception Handling")

Author Comment

ID: 9639577

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

Author Comment

ID: 9641381
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 86

Accepted Solution

jkr earned 1100 total points
ID: 9642277
>>Are the com pointers somehow not threadsafe?

That depends on the COM object they are pointing to - see http://support.microsoft.com/default.aspx?scid=kb;en-us;150777 ("INFO: Descriptions and Workings of OLE Threading Models")

Author Comment

ID: 9660342

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.

LVL 86

Expert Comment

ID: 9660389
Thank you!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question