Logger.Write not executing in event handler

Topics: Logging Application Block
Aug 7, 2008 at 3:02 PM
Using .net 3.5. C#:

I have a datagridview on a form, and an event handler for DataError event which may occur form on load, when binding a data source to the datagridview

private void DataGridView_DataError(object sender, System.Windows.Forms.DataGridViewDataErrorEventArgs e)
Logger.Write(...); // this line is not excuting

I also duplicated the Logger line into the Form_Load event handler just before the line of the binding, and it works.
I was wondering if it has to do with thread problem. Anyone knows what the deal is ? Thanks ~ =]
Aug 7, 2008 at 4:59 PM

The call to Logger.Write() shouldn't be different to any other statement. What do you mean by "not executing"? Is it that expected entries are not logged or that the program literally does not execute the statement?

Is it possible the parameters in the Logger.Write call in your event handler cause the entry to be filtered out?

Aug 7, 2008 at 5:32 PM
Hi Fernando,

Excuse my lack of clarity in the post; let me rephrase it.

Basically no log is generated from the line Logger.Write(...); when it is in the DataError handler method. This line, however, is executed.
But, when the exact same line is placed in Form_Load handler method, just before the line assigning the bindingsource of the datagridview (bindingsource.DataSource = ...) the log is generated without any problems.

And chances of filtered out parameters are very unlikely, as there is only one category, and configuration is with everything (filter = All) is logged.

Aug 8, 2008 at 4:04 PM

This is strange. I can't see how logging from a data error event handler would be different from logging from the load event handler.

I can only suggest you debug the second logging request to determine what's wrong; you can grab EntLib's pdb files from http://www.codeplex.com/entlib/Release/ProjectReleases.aspx and use a fresh copy of the source code to debug.