Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sample 3.5 Framework with Exception Handling / Loggin

Posted on 2010-09-06
10
Medium Priority
?
759 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 668 total points
ID: 33614754
0
 
LVL 10

Assisted Solution

by:james-ct16
james-ct16 earned 668 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 17

Assisted Solution

by:Zhaolai
Zhaolai earned 664 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

783 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