Print Page | Close Window

WebBrowser Application Error

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Active-X COM Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=10216
Printed Date: 20 May 2024 at 9:08am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: WebBrowser Application Error
Posted By: LightRock
Subject: WebBrowser Application Error
Date Posted: 14 April 2008 at 3:21am
Hi
 
I am receiving an application error when hosting a WebBrowser control within a VB ActiveX control and using the SetObjectForScripting (if you remove it there is no error).
 
I guess it is a problem with the clean up when the control is destoyed (it happens on exit of the .exe or VB itself in design time).
 
I am hosting your control in another because I extensively use the MSHTML functionality for HTML editing but also need the ability for HTML to call functionality within the application.
 
Any thoughts?
 
David



Replies:
Posted By: Oleg
Date Posted: 14 April 2008 at 4:08am
Hi,
Small sample will be great :)


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: LightRock
Date Posted: 14 April 2008 at 4:37am
https://forum.codejock.com/uploads/20080414_042921_codejock.zip - uploads/20080414_042921_codejock.zip
 
Hi
 
Attached is a sample of both control and app in the most basic form possible. If you build and register the control and then build the app, the error occurs when closing the .exe.
 
(Environment: VB6 (SP5) Extreme 11.2.2 / Windows 2000 (SP4) or XP)
 
Thank you
 
David
(Can only assume it's to do with binding the function on the control rather than a form)
 


Posted By: Oleg
Date Posted: 14 April 2008 at 7:01am

Thanks.

Ye, problem that need to release ObjectForScripting.
 
You can add public method and call it from container:
 
Public Sub BeforeUnload()
    WebBrowser1.SetObjectForScripting Nothing
End Sub
....
 
Private Sub Form_Unload(Cancel As Integer)
UserControl11.BeforeUnload
End Sub


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: LightRock
Date Posted: 14 April 2008 at 7:42am
Thanks Oleg, works a treat!


Posted By: LittleJK
Date Posted: 04 August 2008 at 3:51pm
Hi we are having a similar problem but we cannot get the scripting errors to stop by using webbrowser.setobjectForscripting. We have the webbrowser control inside of our application.

below is the snippet of where we are calling it. When we set the setobjectforscripting... it still comes back with scripting errors


Private Sub Form_Load()
   
    On Error GoTo handle_error
   
    Screen.MousePointer = vbHourglass
   
    sDefaultPage = "http://intranet.woodloch.com/roomready"
   
    Me.web.Navigate sDefaultPage
    Me.web.setObjectForScripting Me

    bFrmLoaded = True
   
    GoTo doneSub
   
handle_error:
    bFrmLoaded = False
    Call objErrHandler.HandleError(Err.Number, Me.Name & ".Form_Load", Err.Description)
  
doneSub:
    Screen.MousePointer = vbDefault
   
End Sub


Posted By: LightRock
Date Posted: 05 August 2008 at 1:30am
Hi
 
You can stop the standard script warnings by simply adding:
 
WebBrowser1.ScriptErrorsSuppressed = True
 
However it does require the 'Disable script debugging' in the advanced settings of IE to be checked, otherwise you get a debug error.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net