WebDriverBackedSelenium Wait Time Out Was unhandled. - c#

webdriverbackedselenium throwing unhandled exception when use WaitForPageToLoad(timeout);
Even i have try catch
try
{
selenium.WaitForPageToLoad(timeout);
}
catch
{
}
Catching its exception, but when it comes out of catch, showing this image
Tried many solutions but didn't succeeded , please advise what should i Do.
Thank you.

You may configure the Exception Assistant dialog in the way to receive or not receive the exception even if you have the catch block. The solution in the Exceptions configuration you have. Please see it under Debug->Exceptions menu. If the exception checkbox is checked you will receive the Exception Assistant dialog (under debug!) even you have the catch block in your code.
Please see more details and pictures here

Related

LibreOffice Stopped working , while converting XLS to XHTML files using C# application

In this, my queries are,
How to handle LibreOffice Exceptions in C#.
If could not handle , how to pro-grammatically close this exception or to suppress this exception popup, while excuting console
OR any better solution, that my conversion process , should not stop because of unhandle exception caused by Libre Office.
From the image, it looks like the exception got thrown from storeToUrl() in the code at https://github.com/caolanm/unoconv/blob/master/unoconv.
unoconv is a command line tool, not a library, so it does not seem possible to catch the error with a try/catch block. Perhaps you could capture the process's error stream and parse it to see if an exception occurred.
Instead of using unoconv, it may be better to call storeToUrl() directly in C# using the UNO API, with a try/catch for com.sun.star.io.IOException.
When doing many automated conversions with LibreOffice, it is typically necessary to kill the process whenever it gets stuck: https://github.com/dagwieers/unoconv/issues/352.
Firstly, thank you all for your kind help.. :). Finally i resolved.
While bulk file conversion , my c# process, was getting interrupted , because of some exception occurred in LibreOffice process(soffice). so i started killing my c# process and its child processes and also killed soffice. So for next file, fresh soffice is getting created , as i executed unoconv command.
but still, i get the exception popup, but the c# process , keeps continue..
this code helped me

When does Silverlight show "Debugging resource strings are unavailable." message?

I have had a few reports of a message box showing up on application launch with the following contents:
[Arg_NullReferenceException]
Arguments:
Debugging resource strings are unavailable. Often the key and arguments provide
sufficient information to diagnose the problem. See http://go.microsoft...
I understand the link provided gives me the exception detail, and I obviously have a null ref somewhere. I haven't been able to reproduce this, so I am trying to find where this message is being thrown and hopefully add some error handling.
Is this specific message box something baked into Silverlight, or is it following whatever exception handling is in place when such an exception occurs? In the app constructor, I have
this.UnhandledException += this.Application_UnhandledException;
which is:
private void Application_UnhandledException(object sender,
ApplicationUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.ExceptionObject.Message + "\n" + e.ExceptionObject.StackTrace);
}
So it looks like this message box is not coming from the Application_UnhandledException or it would have a message, newline, then a stack trace. So now my two options for how this message box is being generated are: 1) Silverlight is doing it in the background, or 2) this is coming from an existing catch block, although I have found none that would display in this way.
I'm doing offline caching of XAPs in Isolated Storage using OfflineCatalog, which involves some asynchronous WebClient downloads and fall-backs to Isolated Storage when requests fail. It makes sense that a null ref might be happening somewhere in this process.
To summarize, I'm wanting to add some exception handling for this Null Reference, but cannot reproduce it locally, and cannot find where it may be coming from. If this is coming from an unhandled exception, why does it not display the message and stack trace as specified?
The error message occurs if the machine does not have Silverlight SDK installed normally.
To debug similar browser side exceptions, it is common practice to use Visual Studio. If you cannot use VS, simply use WinDbg to attach to the browser process.

Unhandled exception swallowed (except in debugger)

I'm maintaining a legacy C# Winform application, using .NET 4.0 framework. The application works fine, but occasionally due to bugs in the application, the application will fail to work properly when the the application creates invalid data in the database.
At certain points, we bind the (invalid/corrupt) data to a datagrid, which causes numerous errors when it attempts to map a null column to a datagrid column.
An exception of type 'System.InvalidCastException' occurred in mscorlib.dll but was not handled in user code
Additional information: Object cannot be cast from DBNull to other types.
As well as
An exception of type 'System.Reflection.TargetInvocationException' occurred in System.Windows.Forms.dll but was not handled in user code
The errors cause a nice popup to show when run under the Visual Studio debugger detailing the error as well as allowing me to see the line where the error occurred.
In this particular case, I know what the issue is, so I can easily correct it. However, this class of error occurs too-often in other parts of the application, so it's not always obvious what is happening, and my users don't always provide good error reports. To try and combat this, I'd like to add logging to the application (using log4net), which works in our situation as each user has their own copy of the application so I can obtain per-user logs after the fact.
Using hints from stackoverflow as well as various other sources, I found a lot of good information on setting up handlers for these unhandled exceptions. Unfortunately, my handlers are not being called for the majority of the 'unhandled' exceptions.
The mostly relevant parts of the application are below:
static class Program {
private static readonly ILog log = LogManager.GetLogger("Main");
static void Main() {
// Add some error handlers which log error data to the logfile
//
// For UI events (set the unhandled exception mode to force all Windows Forms
// errors to go through our handler)
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
Application.ThreadException += new ThreadExceptionEventHandler(delegate(object s, ThreadExceptionEventArgs e) {
ExceptionLogger(e.Exception);
});
// Non-UI thread exceptions
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(delegate(object sender, UnhandledExceptionEventArgs e) {
ExceptionLogger(e.ExceptionObject as Exception);
});
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
log.Debug("Starting Application");
Application.Run(mainForm = new MainForm());
}
private static void ExceptionLogger(Exception e) {
log.Error("Unhandled Error", e);
string errorMsg = "An application error occurred. Please contact the administrator with the following information:\n\n";
errorMsg = errorMsg + e.Message + "\n\nStack Trace:\n" + e.StackTrace;
if (MessageBox.Show(errorMsg, "TLMS Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Stop) == DialogResult.Abort)
Application.Exit();
}
The Exception handler seems to work if the errors occur directly in my own code, but the handler is not called if/when the errors occur directly in the .NET libraries, and I want the handler called for all Unhandled exceptions, including those outside of code I've written.
Being able to use the debugger to track down the errors is invaluable if I can recreate the exact users steps within the debugger after the fact. However, at no point is ExceptionLogger being called, either running standalone or inside the debugger, and there is no visual indication that any error occurred. Because the exceptions are being suppressed, the users sometimes don't realize until much too late that everything they've done is completely screwed up and the data is even more corrupt.
The application platform is being built and run on x86 (apparently exceptions can be lost if run on x64), and the application has been tested on both 64-bit and 32-bit platforms with no change in behavior.
So you only see "but was not handled" when the app runs in the debugger. When it runs outside the debugger exceptions are suppressed. If I've got this correct then I still think the app handles the exceptions, because the debugger changes app behaviour sometimes.
I confirmed that InvalidCastException is one of a group of exceptions that .NET 4+ handles differently if the exception context is unmanaged code. An app can override this special handling (see All about Corrupted State Exceptions in .NET 4), but the debugger may ignore the override. There are lots of web resources on this, see also one in MSDN Magazine.
EDIT: If your app users have .NET 3.5 or below installed then the app need not apply the override described in the resources above.

How to know which line of code in Try block generates error

Currently I have a block of code with try and catch. In try block i have used some logic based on IO and Database, Now how to know that which line of code generates / getting an exception in try block for io or db related code.
Its Pretty Simple in .Net. In Your .Net Window Press Ctrl + Alt + E. The Exceptions window will be opened. There you can see Common Language Runtime Exceptions Enable those two check boxes. You can get the Error line when ever the Exception is occurred. After pressing F5 it will goes to catch block.

Forcing an app to close when getting error 0xc0000005

I have a C# WPF app that display an error dialog with the error code 0xc0000005. I researched this error code and found that it is a access violation error and could be caused by several things including native code errors (p/invoke and 3rd party dlls). Restarting the app seems to clear the error but I want to be able to force the app to close when that error occurs. Since it is not a managed code exception it is not caught in the try catch blocks, is there any way to force the app to close when this error occurs?
You can catch native exceptions in different way. Either using Win32Exception or SEHException exception class or using catch without any exception type specified as
try
{}
catch
{}
Refer this for details: Can you catch a native exception in C# code?
Use Environment.Exit(0); to terminate your application.

Categories

Resources