.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Post New Web Links

Global Exception Handling

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :Windows Application
 
Hi,   I followed thsi link to implement gloabl exception Handling in winforms app   http://msmvps.com/blogs/deborahk/archive/2009/09/02/global-exception-handler-winforms.aspx?CommentPosted=true#commentmessage   I am geting thwe following errors on this line in the main   Public Shared Sub Main() Application.ThreadException += New ThreadExceptionEventHandler(Application_ThreadException) ' --Errors here on this line   Dim dlg As New frm_Login   If dlg.ShowDialog() = DialogResult.OK Then   Dim frm As New frmMDI_Manager frm.ShowDialog()   End If   End Sub   Error 7 'Public Shared Event ThreadException(sender As Object, e As System.Threading.ThreadExceptionEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.  Error 8 Delegate 'System.Threading.ThreadExceptionEventHandler' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor.  Can any one suggest how to get it working? Thanks  


View Complete Post


More Related Resource Links

Global Exception Handling with ASP.NET

  
After your global exception handler has done its work, you'll want to redirect the users of your website to a friendly page that tells them that something has gone wrong, and then provide them with customer support information as well as a link back to your web application's home page.

Exception handling in Global.asax of ASP.net

  

I want to handle exceptions in my applications in Global.asax and transfer the exception to my custom error page, so that is in a central place. I want to take this exception object into my oopserror.aspx page and format it and display a custom message. i tried to use GetLastError() in my oopsError.aspx page, but my exception object was always null. Following is the code snippet that i'm using and i'm getting exception.

void Application_Error(object sender, EventArgs e)
{
   // Code that runs when an unhandled error occurs
   Exception exception;
   exception = Server.GetLastError();

   Session.Add("Exception", exception);

   Response.Redirect("~/Pages/OopsError.aspx");
}

Following is the exception when the above code is executed.

{"Session state is not available in this context."}
   at System.Web.HttpApplication.get_Session()
   at UserInterface.Global.Application_Error(Object sender, EventArgs e) in C:\UserInterface\Global.asax.cs:line 51
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Web.HttpApplication.RaiseOnError()

Is there a way that i can securly take my session object from global.asax to my oopserror.aspx? Any ideas?


WCF Global Exception Handling

  

 

In Web Applications, you can tap into Application_Error in Global.asax

 

In ASMX Web Services, you can write a Soap Extension where you can get at any exception before it gets sent to the client

 

How can I have global exception handling in WCF services hosted in IIS?

 

At the moment, I've got Try Catches on every one of my methods (in the Catch I then simply call a generic exception handler).

 

Is there a better way? Basically I don't want to have to put Try Catches in each of my methods.


EXCEPTION HANDLING IN C#

  
Every self-respected programmer should include exception handling techniques. Sometimes your application will generate an error. Regardless of who was responsible for this error, the programmer or the user, it is up to the first to include the necessary exception handling techniques to keep his/her program from crashing. The .Net environment provides useful techniques for avoiding disastrous errors such as try-catch statements and user-defined exceptions.

SQL Server 2005 Try and Catch Exception Handling

  
I'm pretty excited to see that there is some real error handling for T-SQL code in SQL Server 2005. It's pretty painful to have your wonderfully architected .NET solution tainted by less-than-VBScript error handling for stored procedures in the database. The big difference being the addition of TRY..CATCH blocks. Let's take a look:

Error while using exception handling block el 4.1

  

Hi Folks,

 

i am trying to use tyhe exception handling block of Enterprise library 4.1.

 

I just createda polisy and used IndexOutOfRangeException and added a replace handler and a logging handler to it.

I am using the NotifyRethrow PostHandlingAction to the exception.

 

During runtime I am getting an exception on the HandleException event, The exception is added below:

 

 

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 42:             catch (Exception ex)
Line 43:             {
Line 44:                 bool reThrow = ExceptionPolicy.HandleException(ex, "ReplacePolicy");
Line 45:         

Data Points: SQL Server 2005 XML Support, Exception Handling, and More

  

SQL Server 2005 includes several important improvements to the Transact-SQL (T-SQL) language. One added feature is a new kind of trigger that fires when data definition language (DDL) statements run.

John Papa

MSDN Magazine May 2006


Error Handling: Throwing Custom Exception Types from a Managed COM+ Server Application

  

Exception handling semantics in .NET are based on type, so you can create custom exceptions that have their own properties and methods. In .NET, exceptions are first-class citizens, and since they're the built-in error handling mechanism, all .NET-compliant languages must support exceptions. In addition, COM+ services are available to .NET code as Enterprise Services, so you can leverage exceptions in your Enterprise Services design.In this article the author describes custom exceptions, throwing exceptions across COM interop boundaries, and working with Enterprise Services.

Bob DeRemer

MSDN Magazine March 2004


Bad email address exception handling

  
 I have a form that used to send an email to someone who had posted  a listing on my site, with a copy to the sending user. The code below is intended to catch the exception that occurs when email address of the person posting the listing (TxtBxTo.Text) is not valid, and also intended to catch the (unlikely) event that the user has entered and confirmed an invalid email (TxtBxEmail.Text) for himself on the form. I have tested this code for all combinations of valid and invalid email addresses for the listing poster and the user filling out the form and sending the email Everything works fine except for the situation where the email address for the listing poster is valid but that of the user  is invalid. In this situation I am getting the message on the ConfirmResaleEmail.aspx page that says: "Your message has been sent to the contact person, with a copy to you. " when I should be getting "Woops, it looks like your own email failed when we tried to send you your copy. " I am hoping some sharp-eyed person can spot the problem.  Here is the code:         ' this sends email from a user with email TxtBxEmail to the contact perons listed in TxtBxTo        msg = New MailMessage(TxtBxEmail.Text, TxtBxTo.Text, TxtBxSubject.Text, sb.ToString())    &n

Exception handling in EventHandlers, Sharepoint

  
What i am doing is when a user upload or edit any doc in a doc library then automatic mail should go to some users. I have written mail sending code in ItemAdded event . My problem is if any exception occurs in my Mail code i want to show that to the user so that he can manually send mails to the concerned users. I have tried using Properties.Cancel=true; but it is not working neither i am able to redirect the user to some custom error page.  I know if i use ItemAdding Event then these codes will work  but i do not want to cancel the document uploading process . Because if i am able to throw the exception then user can manually send the mail. Please suggest how can i show exception message to the user.

Exception Handling for oracle & sqlServer

  
Hi,   My application is working with two databases based on the data providers, now i want to implement the enterprise library exception handling mechanism.. please help me : 

How to create a Custom Exception Handler using Micorosft Exception Handling Application Block?

  
Dear Friends,Can any one let me know "How to create a Custom Exception Handler using Microsoft Exception Handling Application Blocks"I will be having a set of Exceptions which will be getting maintained in an XML File along with the User Friendly Messages for a particular Exception. Whenever an Exception occurs in the projects first it need to check with the Exceptions present in the XML File and need to display the concerned user friendly message for that particular exception to the user..I am not able to get an idea on "How to start with the Microsoft Exception Handler Application Block" to achieve this". Please help me in this regard...Thanks and Regards,G.V.N.Sandeep.

unable to config the enterprise library exception handling for oracle

  
Hi unable to config the enterprise library exception handling for oracle any help?   Thanks in advance :-)

handling dll Exception

  

In WPF application, iam using third party dll (Mapsuite for Maps).

In some scenarious an unhandled nullReferenceException is occuring in dll,

try catch is not able to handled that exception.

how to handled that exception.


PS.Shakeer Hussain Hyderabad

Exception thrown when handling Window.Loaded event

  

Why is the exception assistant not "fired" in a debugging session when a Window.Loaded eventhandler calls code which throws an exception ?
E.g.
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Application.Current.DispatcherUnhandledException +=
               new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
            int a = 1;
            int b = 0;
            int c = a / b;
        }

        void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
        }

Removing the comment signs (//) thus presenting an UnhandledException handler devinately makes the assistant "firing".
Is this behaviour by desi

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend