I declared a LoggingExceptionHandler in my ExceptionHadling block. The logging exception handler writes to a file.
In code, i try to change the EventId, and i get exception with the message "The configuration is read only".
This worked in the previous version of entlib, but stoped working with entlib Jan2006.
Is there a way to change the eventId in runtime ?
Can you show the code for EntLib 2.0 where you try to change the EventID during runtime?
The EventID is specified by you in the app.config or web.config when you are adding the LoggingHandler to the Exception via the Configuration Tool.
This value is then passed to the LoggingExceptionHandler Class in its constructor and the private member is set as ReadOnly, which would suggest you cannot change it.
If you are trying to pass additional runtime data to be logged with the exception, you can add it via the Data Collection of the exception class. This data gets passed to the logwriter in its ExtendedProperties collection and displayed in the log.
catch (NullReferenceException ex)
// Add Some Run-Time Information
ex.Data.Add("Note1", "Some note...");
ex.Data.Add("Note2", "Some note...");
Other than creating the LoggingExceptionHandler Class directly, I don't know of a way to change the EventID at runtime. Adding additional data to the Exception as mentioned above, however, may meet your needs.
Microsoft MVP C#