FIX: Second Time Print from WebBrowser Causes AV in MSHTML.DLL

Last reviewed: August 26, 1997
Article ID: Q169436
The information in this article applies to:
  • Microsoft Internet Explorer (Programming), versions 3.01, 3.02 on the following platforms: NT, Win95

SYMPTOMS

Attempting to print the contents of a WebBrowser control for the second time in Internet Explorer 3.x causes an Access Violation error in Mshtml.dll.

RESOLUTION

Use the following steps to work around the problem:

  1. Download the IE 3.02 File Upload Add-on from the Microsoft download site: http://www.microsoft.com/msdownload/ieplatform/iewin95.htm

    This add-on, in addition to the File Upload support, includes a fix for this WebBrowser printing problem.

  2. Execute the following code to force MSHTML out of memory, and then reload it, restoring its reference count:

          HMODULE hmod;
    
          int    i = 0, j;
    
          // Try to remove MSHTML from memory
          while( hmod = GetModuleHandle("MSHTML") )
          {
             FreeLibrary(hmod);
             i++;
          }
    
          // Restore MSHTML's refcount
          for (j = 1; j <= i; j++)
          {
             LoadLibrary("MSHTML");
          }
    
    

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in the IE 3.02 File Upload add-on release.

MORE INFORMATION

Steps to Reproduce Behavior

From an application that hosts the WebBrowser control:

  1. Open a window containing the WebBrowser control.

  2. Navigate to any URL, such as http://www.microsoft.com.

  3. Print the contents of the WebBrowser.

  4. Close the window containing the WebBrowser control.

  5. Reopen the window containing the WebBrowser control, navigating to any URL.

  6. Print the contents of the WebBrowser control (second time).

  7. A dialog box pops up indicating an Access Violation has occurred in Mshtml.dll.

REFERENCES

For information on how to print from the WebBrowser control, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q156732
   TITLE     : HOWTO: Print from the Microsoft Web Browser Control

For more information on the IE 3.02 File Upload add-on, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q165287
   TITLE     : Description of Internet Explorer 3.02 File Upload Add-On
Keywords          : AXSDKWebBrowser
Technology        : kbInetDev
Version           : 3.01 3.02
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.