Solved

Problem with WebBrowser2 based class

Posted on 2003-10-28
6
431 Views
Last Modified: 2007-12-19
Hi,

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);
            SysFreeString(bstr);
            
            if(strcmp(string, label)==0)            {
                  hr = pHyperlink[i]->click();
                  if(hr!=S_OK) return 1001;
                  break;
            }

            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
0
Comment
Question by:david_johns
  • 3
  • 3
6 Comments
 
LVL 86

Expert Comment

by:jkr
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")
0
 

Author Comment

by:david_johns
ID: 9639577
jkr,

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
0
 

Author Comment

by:david_johns
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
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 86

Accepted Solution

by:
jkr earned 275 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")
0
 

Author Comment

by:david_johns
ID: 9660342
jkr,

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:

http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20784141.html

Thanks for you help.

David
0
 
LVL 86

Expert Comment

by:jkr
ID: 9660389
Thank you!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now