Solved

Sample 3.5 Framework with Exception Handling / Loggin

Posted on 2010-09-06
10
749 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now