Solved

Sample 3.5 Framework with Exception Handling / Loggin

Posted on 2010-09-06
10
753 Views
Last Modified: 2013-11-08
Hi Experts!

Do you have a sample console app that has 3.5 framework using Loggin to the Event log?
Please provide the app.config as well.

A simple example

sub Main()
  ProcSomeThing()
End Sub

Private Sub ProcSomeThing()

Try
 ...
Catch ex as exception
 'Log ex.Message to the Event Log
End Try

End Sub

TIA!
0
Comment
Question by:allanau20
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 167 total points
ID: 33614754
0
 
LVL 10

Assisted Solution

by:james-ct16
james-ct16 earned 167 total points
ID: 33614755
Howdy

I think this may be what you are looking for http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx this is the msdn page for the event log class in the system.diagnostics namespace. you will find further down the page the type of example you are looking for.

After reviewing the little article and code sample you still want the code flushing out in your simple example I am happy to do so.

Regards
James
0
 
LVL 5

Author Comment

by:allanau20
ID: 33619248
sorry, I should've said how to write to the event log with the Enterprise LIbrary 4.0 using the Exception Handling and Loggin blocks.

0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 166 total points
ID: 33621268
0
 
LVL 5

Author Comment

by:allanau20
ID: 33622065
Hi Zhaolai,

Yeah, I dl sample code before posting. This is the error I'm getting:

An error occurred creating the configuration section handler for exceptionHandling: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx' or one of its dependencies.

In my VS 2008 I added the references:

Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging
Microsoft.Practices.EnterpriseLibrary.Logging

And Imported them above my code.

I did not GAC them

Any ideas? Thx!
0
 
LVL 17

Expert Comment

by:Zhaolai
ID: 33622172
Which example are you running?
0
 
LVL 5

Author Comment

by:allanau20
ID: 33622177
getting closer:

so, with this:
            ExceptionPolicy.HandleException(ex, "Default Category")
I get this error:

The type initializer for 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy' threw an exception.

exception-and-loggin-block.jpg
0
 
LVL 5

Author Comment

by:allanau20
ID: 33622192
I downloaded the 4.0 example; not running any of the example.

Just my code as descrbed above.

sub Main()
  ProcSomeThing()
End Sub

Private Sub ProcSomeThing()

Try
 ...
Catch ex as exception
            ExceptionPolicy.HandleException(ex, "Default Category")
End Try

End Sub
0
 
LVL 5

Author Comment

by:allanau20
ID: 33623243
I meant this:  ExceptionPolicy.HandleException(ex, "Global Policy")
0
 
LVL 5

Author Comment

by:allanau20
ID: 33623475
ok; I figured it out. when I downloaded the quickstart and since I have the signed company version on my puter .. there was a mixed up of which dll VS 2008 was referencing to.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question