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<mpl=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
Post a Comment