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.
Solved! Go to Solution.
Solved by Balaji_Ram. Go to Solution.
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.
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
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
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
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
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.
Hi,
Later today i will try with w8 and AutoCAD 2013, I'll let you know the results.
Gaston Nunez
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)]
Sorry for the delay in responding, this week was quite complicated.
Thank you for the tip, it worked very well.
Gdiael