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
Solved

Sample 3.5 Framework with Exception Handling / Loggin

Posted on 2010-09-06
10
752 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
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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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