Skip to main content

How to disable Script Error in WPF


Symptoms-



  • while the application launch after the  3 min  expiry of session expired and  the script generate an error like this



Video Captured Result -Application Error Like-this

Code Fix-Result




Work Around-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ScriptErrorSuppress
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            browser.Navigate("https://accounts.google.com/signup/v2/webcreateaccount?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&ltmpl=default&dsh=S-1979057207%3A1569564750984034&gmb=exp&biz=false&flowName=GlifWebSignIn&flowEntry=SignUp");
            browser.Navigated += new NavigatedEventHandler(WebBrowser_Navigated);
        }
     
        void WebBrowser_Navigated(object sender, NavigationEventArgs e)
        {
            HideJsScriptErrors((WebBrowser)sender);
        }
        public void HideJsScriptErrors(WebBrowser wb)
        {
            // IWebBrowser2 interface
            // Exposes methods that are implemented by the WebBrowser control
            // Searches for the specified field, using the specified binding constraints.
            FieldInfo fInfo = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
            if (fInfo == null)
                return;
            object obj = fInfo.GetValue(wb);
            if (obj == null)
                return;
            // Silent: Sets or gets a value that indicates whether the object can display dialog boxes.
            // HRESULT IWebBrowser2::get_Silent(VARIANT_BOOL *pbSilent);HRESULT IWebBrowser2::put_Silent(VARIANT_BOOL bSilent);
            obj.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, obj, new object[] { true });
        }


    }
}




Comments

Popular posts from this blog

Re-sharper Trial Expires Re-usability- Tricks

Re-sharper Trial Expires Re-usability-  Tricks  Re sharper It is a popular developer productivity extension for Microsoft Visual Studio. It automates most of what can be automated in your coding routines. It finds compiler errors, run-time errors, redundancies, and code smells right as you type, suggesting intelligent corrections for them. Note: This document describes precise after the trial expiry of the re-sharper how we can configure on Next 30 Days validity Pros:Development must easier while loading all the Re-sharper Components; Configuration: Uninstall the application from the Control Panel Remove the system Registry entry default Parameter from the below location-HKEY_CURRENT_USER/Softwares/JetBrains(delete the jetbrains folder) Remove the PrgrammeDataFolder behind the sub folder JetBrains Remove the User AppData folder. For all the use cases Done user can restart the Machine After that user able to  Re-install the application ...

How to execute Python Script in PyCharm-Configuration