4

What happens when I close my app, which uses webbrowser. The following url uses flash player.

alt text

Everything works fine. This error shows on app close. How do I ignore it?

2
  • 1
    I hope you don't use the same principle when you see errors/warnings from your compiler. "It works fine, so how do I hide the errors?" is never a good question to be asking. Commented Jan 11, 2011 at 8:50
  • IE nor FF nor Chrome shows such errors. So why should I take attention at some activex control?! Commented Jan 11, 2011 at 8:57

5 Answers 5

5

I know it's too late, but I feel I have a smart answer for this issue.

Use this, it's working for me on a fly. :)

webBrowser.ScriptErrorsSuppressed = true;

If it's not working, we can use different methods like showing a confirmation box (Ex: This windows want to close do you want to continue Yes/ No)

[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
    static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName);

[DllImport("user32.dll")]
        private static extern bool SetForegroundWindow(IntPtr hWnd);

 private void TimerPopUp_Tick(object sender, EventArgs e)
        {
            IntPtr hWnd1 = FindWindowByCaption(IntPtr.Zero, "Web Browser");

            if (hWnd1 != IntPtr.Zero && SetForegroundWindow(hWnd1))
            {
                SendKeys.Send("{Enter}");
            }

        }

If there are any errors, see this link.

Sign up to request clarification or add additional context in comments.

Comments

2

You can disable javascrip errors by setting ScriptErrorsSuppressed property of WebBrowser control to true. It may not work sometimes though. If it does not work, check http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/46a32b08-3834-4a13-8170-e0eba2498284 and http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/07df5263-613c-4780-89a2-67ebf2a1e670

Comments

1

In Visual Studio 2015, there is an option that can enable or disable the popups.

In web browser propertiesScript Errors Suppressed, then set it to True to disable the popups.

Comments

0

First you need to know that the webbrowser control is using IE7 as its base (i.e. the older version of Internet Explorer ) so the scripts which you are running now are compatible with the modern age browsers and thus the error. First of all, if you'll put:

<meta http-equiv="X-UA-Compatible" content="IE=edge"/>

inside your section of the page, it will render with the IE version installed on the machine instead of the default IE 7

Hope this Helps!

Comments

0

You should make the WebBrowser Control COM Visible and give it the proper permissions:

#region Using Statements:



using System;
using System.Windows.Forms;
using System.Security.Permissions;



#endregion



[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class Form1 : Form
{



public Form1()
{

InitializeComponent();

// WebBrowser Configuration:
webBrowser1.ObjectForScripting = this;
webBrowser1.AllowWebBrowserDrop = false;
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.WebBrowserShortcutsEnabled = false;
webBrowser1.IsWebBrowserContextMenuEnabled = false;

}




private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.google.com/");
}


}

or:

#region Using Statements:



using System;
using System.Windows.Forms;
using System.Security.Permissions;



#endregion



[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public partial class Form1 : Form
{



public Form1()
{

InitializeComponent();

// WebBrowser Configuration:
webBrowser1.ObjectForScripting = new ObjectForScripting();
webBrowser1.AllowWebBrowserDrop = false;
webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.WebBrowserShortcutsEnabled = false;
webBrowser1.IsWebBrowserContextMenuEnabled = false;

}




private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("https://www.google.com/");
}


[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public class ObjectForScripting
{

// User Code to handle events..

}


}

Note: This may not run correctly in debug mode.

Also, if you need the Registry Key set for local App Compatibility, it also wont run in debug mode.

IsWOW64 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";



IsNotWOW64 = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.