Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Component calling WebBrowser2->Navigate crashes in an ASP environment

30 views
Skip to first unread message

DC Dweller

unread,
Nov 6, 2013, 12:30:15 PM11/6/13
to
Hello,

I wrote an object in C++/ATL that converts HTML to image by using the CLSID_WebBrowser control.

It does pretty standard stuff:

CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_SERVER (or CLSCTX_INPROC_SERVER),
IID_IUnknown, (void**)&ptrIUnknown);

ptrIUnknown->QueryInterface(IID_IWebBrowser2, (void **)&m_ptrBrowser2);

also calls SetClientSite, connects to and handles the DWebBrowserEvents2 (BeforeNavigate2, DocumentComplete), does m_ptrOleObject->DoVerb, etc.


In the end, it uses IViewObject->Draw().

Everything works works beautifully when the object is called from a stand-alone application. However, when I call it from a server-side (ASP or ASP.NET) environment, the whole thing crashes very early on, at the line

CComBSTR bstrBlank = L"about:blank";
m_ptrBrowser2->Navigate(bstrBlank, &varEmpty, &varEmpty, &varEmpty, &varEmpty);

I get the nasty 0xC0000005: Access Violation.

I have a .NET application in my possession that does pretty much the same thing, (but written in C#) and it works reasonably well! So apparently this is doable.

Another odd thing is if I compile my C++ project for the AMD64 platform (64-bit) it does not crash but still does not work well, complex web pages still do not convert properly, etc.

I am at my wits end. Any ideas, please? Thanks a lot in advance.

-- DC Dweller

Bjoern Hoehrmann

unread,
Nov 6, 2013, 1:31:25 PM11/6/13
to
* DC Dweller wrote in m.public.inetsdk.programming.webbrowser_ctl:
>Everything works works beautifully when the object is called from a
>stand-alone application. However, when I call it from a server-side (ASP
>or ASP.NET) environment, the whole thing crashes very early on, at the
>line
>
>CComBSTR bstrBlank = L"about:blank";
>m_ptrBrowser2->Navigate(bstrBlank, &varEmpty, &varEmpty, &varEmpty, &varEmpty);
>
>I get the nasty 0xC0000005: Access Violation.

That should not happen if you carefully checked the return values of the
various calls to methods like `QueryInterface` which may fail. Obviously
if, for instance, m_ptrBrowser2 is NULL then this will crash. You should
check on where the code first fails and look up whatever error you get.
One possibility is that this is a configuration problem, the code might,
for instance, lack the needed privileges to use the web browser object.
Users of my http://iecapt.sf.net/ report such problems sometimes.

>Another odd thing is if I compile my C++ project for the AMD64 platform
>(64-bit) it does not crash but still does not work well, complex web
>pages still do not convert properly, etc.

It may be that you attempt to render them too early or in the wrong web
browser mode; IE has various compatibility modes to render web pages and
code that hosts IE has different default behavior which makes some pages
render incorrectly. That can be changed through the registry, keyword is
"FEATURE_BROWSER_EMULATION".
--
Björn Höhrmann · mailto:bjo...@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/

DC Dweller

unread,
Nov 6, 2013, 2:21:35 PM11/6/13
to
Bjorn,

Thanks for replying.

I check all return values carefully and all is well, and m_ptrBrowser2 is definitely not NULL. I can do other things with this pointer such a

m_ptrBrowser2->get_Busy(...);

It is really suspicious that the 64-bit version does not crash, only the 32-bit one. I compiled it using VS 6.0 (very old version of Visual Studio) but the in the stand-alone mode it works fine, so the interface definitions must be correct! I also tried to impersonate an admin account when running this script in ASP, and it still crashes.
0 new messages