BUG: Navigate(2) Causes Access Violation in Shdocvw.dll

Last reviewed: March 17, 1998
Article ID: Q182490
The information in this article applies to:
  • Internet Client SDK, versions 4.0, 4.01
  • Microsoft ActiveX SDK, version 1.0
  • Microsoft Internet Explorer (Programming), versions 3.0, 3.01, 3.02, 4.0, 4.01

SYMPTOMS

Calling Navigate or Navigate2 causes an access violation in Shdowvw.dll. The error that is reported is "(showdocvw.dll): 0xC0000005: Access Violation".

CAUSE

This is caused by passing NULLs to the Navigate or Navigate2 methods like this:

   m_WebBrowser.Navigate2(pUrl, NULL, NULL, NULL, NULL);


Navigate(2) expects a pointers to VARIANTs. The access violation is due to the fact that the WebBrowser control is trying to write to the memory pointed to by one of these parameters. When you pass NULL for one or more of these parameters, the WebBrowser control tries to write to the NULL memory. This causes the access violation.

RESOLUTION

You must pass the address of empty VARIANTs to the Navigate or Navigate2 methods.

Typically, this can be accomplished with the following C++ code:

   VARIANT vtEmpty;
   vtEmpty.vt = VT_EMPTY;

However, using the compiler's native support for OLE is usually much easier. Use the following code to take advantage of the compiler's native support.

   _variant_t vtEmpty;
   // nothing further needed

If you are using MFC, the COleVariant class can be used to created an empty VARIANT. The default constructor for COleVariant sets the type of the VARIANT to VT_EMPTY. Here is the MFC code:

   COleVariant vtEmpty;

Then, you pass the vtEmpty variable to the Navigate or Navigate2 method like so:

   m_WebBrowser.Navigate2(pUrl, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

Please see the "Reusing the WebBrowser and MSHTML" subsection of the "Internet Tools and Technologies" section in the Internet Client SDK online help: http://www.microsoft.com/msdn/sdk/inetsdk/help/.


Additional query words: 0xC0000005 shdocvw.dll
Keywords : AXSDKWebBrowser kberrmsg kbfaq
Technology : kbInetDev ole internet
Version : WINDOWS:1.0,3.0,3.01,3.02,4.0,4.01
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbpending


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: March 17, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.