Custom Exception Handling And Logging using EnterPrise Library app

Custom Exception Handling And Logging using EnterPrise Library app

am 31.03.2008 07:08:00 von Shrikant More

Hi ,
I am looking out for a custom based exception handling and logging
mechanisms using Enterprise library's exception handling and logging
application blocks.I have a class library called Exceptionhandling. I have
created class called Appexception.cs . I have inherited it from
IExceptionHandler.



[ConfigurationElementType(typeof(CustomHandlerData))]

public class AppException : IExceptionHandler
{
Dictionary dictionary = new Dictionary object>();
public AppException(NameValueCollection collection)
{

int count = collection.Count;

}

#region IExceptionHandler Members

public Exception HandleException(Exception exception, Guid
handlingInstanceId)
{

// How can i get the reference of the IDictionary object
return exception;

}

#endregion

}

I also have an Website in which i am adding the reference of the above
class library.The code which i have written in page load is as below,
ublic partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
try
{
int i, j,k;
i = 5;
j = 0;
k = i / j;

}
catch (Exception ex)
{
ex.Source = ConfigurationManager.AppSettings["SODATEXT"];

Dictionary dictionaryError = new
Dictionary();
dictionaryError.Add("username ", Shrikant More);
Guid activityId ;
activityId= Guid.NewGuid();
dictionaryError.Add("Activityid",activityId);
dictionaryError.Add("EventID",eventID);
ExceptionPolicy.HandleException(ex, "Exception Policy");

}


Question : How can i pass the dictionary object to the
ExceptionPolicy.HandleException Method. I have added some values to the
dictionary object, i want that values in the HandleException method of the
AppException.Cs class in the and add that vlaues in the windows log
event.How can i achive this mechanism