Solved

Sample 3.5 Framework with Exception Handling / Loggin

Posted on 2010-09-06
10
755 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
Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

635 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