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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Exception handling in EventHandlers, Sharepoint

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :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.

View Complete Post

More Related Resource Links


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.

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.

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

SharePoint 2010 Excel Service Exception

SharePoint 2010 Excel Service Exception   I created Windows Form Application in Visual Studio 2010. I added Service Reference: http://<SharePoint _Server_Name>/_vti_bin/ExcelService.asmx. The code line: ExcelContract.XLWebService.ArrayOfAnyType returnData =              proxy.GetRangeA1(sessionID, sheetName, nameRange, false, out wsStatus);     throws exception: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/office/excel/server/webservices:GetRangeA1Response. The InnerException message was 'Error in line 1 position 361. Element 'http://schemas.microsoft.com/office/excel/server/webservices:anyType' I have the following app.config: <?xml version="1.0" encoding="utf-8" ?> <configuration>     <system.serviceModel>         <bindings>             <basicHttpBinding>                 <binding name="ExcelServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"             

Global Exception Handling

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  

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 : 

Installing SharePoint 2010 with SQL Server 2008 - SQL Exception - Login Failed

Hello I've been trying to install SharePoint 2010 with SQL Server 2008 in my Windows Server 2008 R2 box. I've got the same error all the times. System Specifications Windows Server 2008 R2 SQL Server 2008 with SP1 SharePoint 2010 Enterprise 6GB RAM, 320GB HDD Installation Steps I followed Installed Windows Server 2008 R2 and joined it to our domain Logged in as domain administrator Installed SQL Server 2008 Selected the Local Service account for all the SQL Server 2008 services during installation Selected Mixed mode authentication Selected 'Add Current User' in all the other installation screens Installed SQL Server 2008 SP1 Installed SharePoint 2010 Selected Farm option Selected Complete Installation Tried to run the configuration wizard and got sqlexception error - login failed But i checked that the current user (domain admin) is having all the permissions. Also added the domain admin as Security Admin and DB Creator in SQL Server instance. Any ideas?  Regards NLV Visit SharePoint User group - India

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 :-)

an unhandled exception occurred in the silverlight application sharepoint 2010

An unhandled exception occurred on the page when Try to create the Announcement List in SP 2010 site which is upgraded from SP 2007,Any body have faced this issue?

SharePoint 2010 : Creating SPSite object throws exception FileNotFoundException

We are in a process of upgrading from SharePoint 2007 to SharePoint 2010. I had written a Service which runs under default web site on the SharePoint web server. This service's app pool account uses the farm admin account. The service was working with no issue on SharePoint 2007 x64bit server. When I installed and run the same service on SharePoint 2010 x64bit box. I get the FileNotFoundException on SPSite site = new SPSite(http://myserver/sites/projects/project01); I have given the pool account running this server following rights: The Farm Admin The Site Collection Admin The Database Sys Admin The Local Admin No Luck. Thank you in advance for your help.
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