.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JavaScript and WebBrowser control error

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Gdiael
2815 Views, 9 Replies

JavaScript and WebBrowser control error

I have a Form with a WebBrowser Control loaded with a html file with javascript, all the javascript functions and interaction with vb.net are working fine, but when I close the Form and open again (or go to another drawing and I try to open it there) happens a fatal error.

 

I've tried several ways and can not understand what is going wrong.
And also googled for people with a similar problem and did not find anyone.

Thanks if anyone can help me.

 

Gdiael Barros.

9 REPLIES 9
Message 2 of 10
philippe.leefsma
in reply to: Gdiael

Hi Gdiael,

 

Can you provide a buildable sample? I will take a look then. It is unusual for AutoCAD developers to use this kind of control, so I am not sure if it is supported while running inside AutoCAD. Did you try reproducing the issue outside of AutoCAD, in a standalone exe, do you notice the same behavior?

 

Thank you.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 10
Gdiael
in reply to: Gdiael

 

Thank you for the attention Philippe.

 

I did several test and I was working on my project since I made the post, and yes, I tried using a separate exe and it worked normally.
Furthermore I noticed that is not my html file that is causing the fatal error, even scripts running on it. In fact any site that I send WebBrowser Control to navigate causes the problem.

I pasted the vb.net code below.

 

I created a new Windows Form with a WebBrowser on it and a button called BtOK.

What happens is that when I call the command WBrowserTest few consecutive times (sometimes an attempt, sometimes several attempts) AutoCAD gives me a fatal error. When I try on a heavy file, occurs on the second attempt (the first always works), in a lighter files takes a few more attempts to fatal error occurs.

I also discovered that the WebBrowser is a resource-intensive control (which I do not know exactly what means, beyond what the word suggests). But Kean put this thing in his blog:

 

"A word of caution: some of these higher levels are extremely resource-intensive. Please do not attempt to play around with something like this while working on something you don't want to lose: there is always a slim chance of the application (and even the system, if you're really unlucky) being brought down when system resources become scarce."

In the end of this post: http://through-the-interface.typepad.com/through_the_interface/2008/07/turtle-fracta-1.html

 

I would greatly appreciate if you can help me even a bit.

 

Gdiael.

 

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports System.Security.Permissions
Imports System.Runtime.InteropServices

<ComVisible(True)>
<PermissionSet(SecurityAction.InheritanceDemand, Name:="FullTrust")>
<PermissionSet(SecurityAction.Demand, Name:="FullTrust")>
Public Class WebBrowserTest

    <CommandMethod("WBrowserTest")>
    Public Sub LoadForm_command()
        Using Dialog As New WebBrowserTest
            Application.ShowModalDialog(Dialog)
            Dialog.Dispose()
        End Using
    End Sub

    Private Sub WebBrowserTest_load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        WebBrowser1.Navigate("www.google.com")
    End Sub

    Private Sub BtOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtOK.Click
        Me.Close()
    End Sub

End Class

 

Message 4 of 10
Alexander.Rivilis
in reply to: Gdiael

Are you sure that you need to call Dialog.Dispose () inside the Using? I.e. it is looking like you call Dialog.Dispose () twice.

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 5 of 10
Gdiael
in reply to: Alexander.Rivilis

Sorry, I know it's not necessary, I put during testing to see if it made any difference and I forgot to remove. But surely this is not what is causing the fatal error.

 

Gdiael

Message 6 of 10
hgasty1001
in reply to: Gdiael

Hi,

 

I can not reproduce the issue with almos exactly the same code (without the double dispose), platform: AutoCAD 2012 and 2013 both on 32 bits (Windows Server 2008 R1 SP1 for AutoCAD 2012 and W7 Ultimate for 2013) iexplorer 8 and 9, VS 2010 SP1 .NET 4.0.

Just a shot in the dark: Update all the components(hot fixes, SPs, etc) in the test system and check again.

 

Gaston Nunez

 

Message 7 of 10
Gdiael
in reply to: hgasty1001

Thanks Gaston, but my system is up to date and AutoCAD has all the updates. Do not know if this is the case, but I'm using windows 8, which is not supported by my version of AutoCAD, yet all my other codes work smoothly, and using AutoCAD normally I never got a fatal error.

Message 8 of 10
hgasty1001
in reply to: Gdiael

Hi,

 

Later today i will try with w8 and AutoCAD 2013, I'll let you know the results.

 

Gaston Nunez

Message 9 of 10
Balaji_Ram
in reply to: Gdiael

Hello Gdiael,

 

Can you try running the command in session context ?

 

I remember having seen an issue with Webbrowser not displaying videos when the command was run in the document context. Running it in Session context had fixed it.

 

The crash that you are observing does not sound similar, but the change is quite simple and easy to try.

 

 

[CommandMethod("WBrowserTest", CommandFlags.Modal | CommandFlags.Session)]

 

 

 

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 10 of 10
Gdiael
in reply to: Balaji_Ram

Sorry for the delay in responding, this week was quite complicated.
Thank you for the tip, it worked very well.

 

Gdiael

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost