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.
Solved! Go to Solution.
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 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_t
I would greatly appreciate if you can help me even a bit.
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
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.
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.
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.
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)]