469,934 Members | 1,857 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

Interop(?) Problem returning bool from C# to WebBrowser Script Error handler

Using the MS C++ Example
http://support.microsoft.com/default...b;en-us;261003 I've
successfully managed to trap and log Script Errors that are generated by the
WebBrowser (IE 6) which is hosted by a C# application, see below. However
I've completely failed to force the browser to continue processing script
which *should* be controlled by returning a true VT_BOOL via pvaOut. I've
tried returning bool, System.Boolean even constructing a Variant object with
various Marshalling options but without any success. Any help or suggestions
on what to try next would be much appreciated.

Thanks in advance for any help

void IOleCommandTarget.Exec(int pguidCmdGroup,
MsHtmlCustomization.OLECMDID nCmdID,

MsHtmlCustomization.OLECMDEXECOPT nCmdexecopt,

ref object pvaIn,

ref object pvaOut) {

if(pguidCmdGroup == 0) return;

switch((int) nCmdID) {


bool DisplayError = true; // Display Standard IE Script Error Dialog

bool ContinueRunningScripts = true; // Continue to run Scripts

HTMLDocumentClass Doc = (HTMLDocumentClass) pvaIn;

IHTMLEventObj2 ev = (IHTMLEventObj2) Doc.parentWindow.@event;

int errorLine = (int) ev.getAttribute("errorLine", 0);

string errorCharacter = ev.getAttribute("errorCharacter",

int errorCode = (int) ev.getAttribute("errorCode", 0);

string errorMessage = (string) ev.getAttribute("errorMessage", 0);

string errorUrl = (string) ev.getAttribute("errorUrl", 0);

if(eScriptError != null) {

DisplayError = eScriptError(this, errorUrl, errorLine,
errorMessage, out ContinueRunningScripts);

// If were not displaying an error message then pause a moment

if(!DisplayError) Sleep(2000);


pvaOut = (System.Boolean) ContinueRunningScripts;

throw new COMException("", (DisplayError ? S_ERROR : S_OK));



Nov 15 '05 #1
0 3414

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by SteveS | last post: by
5 posts views Thread by mcnewsxp | last post: by
3 posts views Thread by DG is a god.... | last post: by
6 posts views Thread by ANeelima | last post: by
reply views Thread by Amy L | last post: by
reply views Thread by akshar108 via DotNetMonster.com | last post: by
4 posts views Thread by Rinaldo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.