473,320 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Unable to Write to Event Log w/ Enterprise Library 2.0 in Win App

Hi,

Thanks in advance for reading this.

Not sure where to post this question, but I hope someone in here can help.

Trying to write to Event Log in VS 2005 (.NET 2.0) using Enterprise Library
2.0
on a XP Pro SP2 Machine

Setup a basic Windows app in Form load's:
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling
Imports Microsoft.Practices.EnterpriseLibrary.Logging
Imports Microsoft.Practices.EnterpriseLibrary.Common

Public Class Form1

Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Try
Logger.Write("Writing to EventLog", "Sample Exception", 0, 100,
TraceEventType.Information, "Sample Title")

Process()
Catch ex As Exception
ExceptionPolicy.HandleException(ex, "Sample Exception Policy")
End Try

End Sub

' Routine that causes an exception to be thrown
Private Sub Process()
Throw New Exception("Original Generated Exception")
End Sub

End Class

-----------------------------------------------------------------------------------

Here's how it looks like with the Enterprise Lib Config tool for the
Execption and Logging blocks:
Exception Handling Application Block
Sample Exception Policy
Name: Sample Exception Policy
Exception
PostHandlingAction: NotifyRethrow
Logging Handler
EVentID: 100
FormaterType:
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.TextExceptionFormatter
LogCategory: Sample Exception
Name: Logging Handler
Priority: 0
Severity: Error
Title: Enterprise Library Exception Handling - Sample App
Logging Application Block
Filter
Category Sources
Sample Exception
SourceLevels: All
Formatted Eventlog TraceListener
ReferencedTraceListener: Formattted EVenlog TraceListener

Special Sources
Logging Errors & Warnings
SourceLevels: All
Formatted Eventlog TraceListener
ReferencedTraceListener: Formattted EVenlog TraceListener
Unprocessed Category
SourceLevels: All
All Events
SourceLevels: All
Trace Listeners
Formatted EVentlog TraceListener
Formatter: TExt Formatter
Log: Application
MachineName: MyWorkstationName
Name: Formatter: TExt Formatter
Source: Enterprise Library Logging - Sample App
TraceOutputOptions: None

-----------------------------------------------------------------------------------

Able to write to the Event log with the write method of the logger class.
But when the exception is thrown, the error below appears.

-----------------------------------------------------------------------------------
System.Configuration.ConfigurationErrorsException was unhandled
BareMessage="The type
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Logging.LoggingExceptionHandler,
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Logging,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=123456789012345b from
configuration could not be created."
Filename="C:\Visual Studio 2005\Projects\Windows
Desktop\WindowsApplication1\WindowsApplication1\bi n\Debug\WindowsApplication1.vshost.exe.config"
Line=47
Message="The type
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Logging.LoggingExceptionHandler,
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Logging,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=37433583d12c9c1b from
configuration could not be created. (C:\Visual Studio 2005\Projects\Windows
Desktop\WindowsApplication1\WindowsApplication1\bi n\Debug\WindowsApplication1.vshost.exe.config line 47)"
Source="System.Configuration"
StackTrace:
at System.Configuration.BaseConfigurationRecord.Evalu ateOne(String[]
keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord,
SectionRecord sectionRecord, Object parentResult)
at
System.Configuration.BaseConfigurationRecord.Evalu ate(FactoryRecord
factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean
getLkg, Boolean getRuntimeObject, Object& result, Object&
resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject,
Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject,
Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at
System.Configuration.BaseConfigurationRecord.GetSe ctionRecursive(String
configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject,
Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String
configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSe ction(String
configKey)
at
System.Configuration.ClientConfigurationSystem.Sys tem.Configuration.Internal.IInternalConfigSystem.G etSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSecti on(String
sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.SystemConfigurationSourceImplementation.G etSection(String sectionName)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.SystemConfigurationSource.GetSection(Stri ng sectionName)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.Configuration.ExceptionHandlingSettings.GetE xceptionHandlingSettings(IConfigurationSource
configurationSource)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionHandlingConfigurationView.get_Excep tionHandlingSettings()
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionHandlingConfigurationView.GetExcept ionPolicyData(String policyName)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyCustomFactory.GetConfiguratio n(String id, IConfigurationSource configurationSource)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicyCustomFactory.CreateObject(IB uilderContext
context, String name, IConfigurationSource configurationSource,
ConfigurationReflectionCache reflectionCache)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.ConfiguredObjectStrategy.Bu ildUp(IBuilderContext
context, Type t, Object existing, String id)
at
Microsoft.Practices.ObjectBuilder.BuilderStrategy. BuildUp(IBuilderContext
context, Type typeToBuild, Object existing, String idToBuild)
at
Microsoft.Practices.ObjectBuilder.SingletonStrateg y.BuildUp(IBuilderContext
context, Type typeToBuild, Object existing, String idToBuild)
at
Microsoft.Practices.ObjectBuilder.BuilderStrategy. BuildUp(IBuilderContext
context, Type typeToBuild, Object existing, String idToBuild)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.ConfigurationNameMappingStr ategy.BuildUp(IBuilderContext
context, Type t, Object existing, String id)
at
Microsoft.Practices.ObjectBuilder.BuilderBase`1.Do BuildUp(IReadWriteLocator
locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[]
transientPolicies)
at
Microsoft.Practices.ObjectBuilder.BuilderBase`1.Bu ildUp(IReadWriteLocator
locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[]
transientPolicies)
at
Microsoft.Practices.ObjectBuilder.BuilderBase`1.Bu ildUp[TTypeToBuild](IReadWriteLocator
locator, String idToBuild, Object existing, PolicyList[] transientPolicies)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.EnterpriseLibraryFactory.Bu ildUp[T](IReadWriteLocator
locator, String id, IConfigurationSource configurationSource)
at
Microsoft.Practices.EnterpriseLibrary.Common.Confi guration.ObjectBuilder.LocatorNameTypeFactoryBase` 1.Create(String name)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicy.GetExceptionPolicy(Exception exception, String policyName)
at
Microsoft.Practices.EnterpriseLibrary.ExceptionHan dling.ExceptionPolicy.HandleException(Exception exceptionToHandle, String policyName)
at WindowsApplication1.Form1.Form1_Load(Object sender, EventArgs e)
in C:\Visual Studio 2005\Projects\Windows
Desktop\WindowsApplication1\WindowsApplication1\Fo rm1.vb:line 13
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow( HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
-----------------------------------------------------------------------------------
--
Thanks in advance for your replies!
Jun 11 '07 #1
0 4578

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Angelos Karantzalis | last post by:
Hi, can anybody point me to some info in how to write to the event viewer ? I've build a COM+ component, and I have no real way to get information on the possible exceptions that occur during...
3
by: Angelos Karantzalis | last post by:
Hi y'all, recently I've come across a situation where a web service needs to deal with an exception that might arise, originating from a COM+ component. It then returns an int value (please...
3
by: veera sekhar kota | last post by:
hi, im seriously looking for right answer .... We are developing windows application in c#. I implemented DAAB(Data Access Application Block) 2.0 in our application. One of the senior asked...
22
by: EP | last post by:
When running my asp.net hosting service (asp.net without IIS), on server 2003 with IIS not installed, I get the following when trying to process a request. "System.DllNotFoundException: Unable to...
0
by: Eniac | last post by:
Hello, I've started using Enterprise Library 2.0 recently and I've encountered a problem that seems to be ... well... undocumented :) Basically, when I set a Trace Listener (formatted event...
1
by: Terrance | last post by:
I'm trying to create a small messenger program that uses the tcpclient and tcplistenter objects. When I start the application and run the thread that fires the tcplistener; once the client sends...
1
by: GaryDean | last post by:
I now have installed (from the same install) Enterprise Library - January 2006 and Enterprise Library - June 2005. The install for these two was called Enterprise Library for .Net 2.0. (not...
5
by: =?Utf-8?B?TWljaGFlbFF1aW5sYW4=?= | last post by:
In my development environment I can add references to the Microsoft Practices libraries and everything works ok. But when I copy the application to the test server I get the message "CS0234: The...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.