I've been attempting to track down a problem in a piece of code all weekend :(
I have a very straight forward piece of code that manipulates data. There isn't an IF or loop or anything in the area I'm working on. The problem is... This code is failing when I pass production volumes of data thru it - and it fails at different spots. I originally wanted to trace the code in a debugger... But the code doesn't fail unless I pass production volumes thru, and sitting waiting for the debugger to locate an exception is a pain! My alternate is to put some Logging into my code and turn it loose on the production volumes of data.
At the top of the code in question, I created a LogInfo variable and an EventLogController. Both VB variables were DIM'd and initialized.
There are 4 places in the code I want to see what's happening. In each spot, I placed code similar to:
' preconfig LogInfo info
objEventLogInfo.LogTypeKey = EventLogController.EventLogType.USER_CREATED.ToString()
objEventLogInfo.BypassBuffering =
True
objEventLogInfo.LogProperties.Clear()
objEventLogInfo.LogProperties.Add(
New LogDetailInfo("Counter is ", _list.Count))
objEventLogController.AddLog(objEventLogInfo)
' Write log entry
The first of the 4 Event Log entries is written perfectly. The second fails with:
Error |
Violation of PRIMARY KEY constraint 'PK_EventLogMaster'. Cannot insert duplicate key in object 'dbo.EventLog'. The statement has been terminated. |
As far as I can tell, this error is caused by the EventLogController having allocated a GUID when this object was created. But, because I'm "reusing" this object, the GUID doesn't get replaced. I looked at the code a bit and didn't see a method I can call that will generate a new GUID.
I did a search of the DNN 5 source tree and didn't find a single case of EventLogController being "reused" within a module. The code I saw allocated both EventLogController and LogInfo and wrote data - either as part of an IF or as the sole logging event within a method. In each case I found, both EventLogController and LogInfo are created anew before they are used.
Anyone know if it's possible to reuse an EventLogController object? And how to generate a new GUID - so I don't get DataBase errors?
Thanks!
Robert