SLAB exception - Reading past end of event

Topics: Semantic Logging Application Block
Mar 22, 2013 at 9:26 PM
I'm attempting to log incoming http requests via the following method in my EventSource:
[Event(1000, Message = "Incoming http request audit", Level = EventLevel.LogAlways)]
        internal void WriteAudit(string RequestMethod, string RequestPath, string RequestUser, string RequestUserIP, string RequestForm, string RequestQuerystring, string RequestBody, string RequestSizeBytes, string RequestHeader)
        {
            string requestJson = "";
            var writer = new StringWriter();
            using (JsonTextWriter jsonWriter = new JsonTextWriter(writer))
            {
                jsonWriter.WritePropertyName("RequestMethod");
                jsonWriter.WriteValue(RequestMethod);
                jsonWriter.WritePropertyName("RequestPath");
                jsonWriter.WriteValue(RequestPath);
                jsonWriter.WritePropertyName("RequestUser");
                jsonWriter.WriteValue(RequestUser);
                jsonWriter.WritePropertyName("RequestUserIP");
                jsonWriter.WriteValue(RequestUserIP);
                jsonWriter.WritePropertyName("RequestForm");
                jsonWriter.WriteValue(RequestForm);
                jsonWriter.WritePropertyName("RequestQuerystring");
                jsonWriter.WriteValue(RequestQuerystring);
                jsonWriter.WritePropertyName("RequestBody");
                jsonWriter.WriteValue(RequestBody);
                jsonWriter.WritePropertyName("RequestSizeBytes");
                jsonWriter.WriteValue(RequestSizeBytes);
                jsonWriter.WritePropertyName("RequestHeader");
                jsonWriter.WriteValue(RequestHeader);
                jsonWriter.Flush();
                requestJson = writer.ToString();
            }
            WriteEvent(1000, requestJson);
        }
At runtime, I get the following error from SemanticLogging-svc.exe -c (via console window):
SourceId : e2897319-dccf-5314-0bf9-429008ed9de0
EventId : 900
Keywords : 4
Level : Error
Message :
Opcode : Info
Task : 64634
Version : 0
Payload : [message : System.AggregateException: One or more errors occurred. ---
> System.Exception: Reading past end of event
   at Diagnostics.Tracing.TraceEvent.GetUnicodeStringAt(Int32 offset) in c:\Buil
ds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\TraceEven
t.cs:line 1111
   at Diagnostics.Tracing.Parsers.DynamicTraceEventData.PayloadValue(Int32 index
) in c:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2
.7\DynamicTraceEventParser.cs:line 745
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.CreatePayload(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\Blo
cks\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 258
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.CreateEventEntry(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\
Blocks\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 298
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.PreprocessEvent(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\B
locks\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 310
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.<Start>b__1(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\Block
s\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 142
   at Diagnostics.Tracing.Parsers.DynamicTraceEventData.Dispatch() in c:\Builds\
71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\DynamicTrace
EventParser.cs:line 714
   at Diagnostics.Tracing.TraceEventDispatcher.Dispatch(TraceEvent anEvent) in c
:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\Tra
ceEvent.cs:line 1716
   at Diagnostics.Tracing.ETWTraceEventSource.RawDispatch(EVENT_RECORD* rawData)
 in c:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.
7\ETWTraceEventSource.cs:line 328
   at Diagnostics.Tracing.Parsers.TraceEventNativeMethods.ProcessTrace(UInt64[]
handleArray, UInt32 handleCount, IntPtr StartTime, IntPtr EndTime)
   at Diagnostics.Tracing.ETWTraceEventSource.Process() in c:\Builds\71\EntLib\S
LAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\ETWTraceEventSource.cs:
line 200
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.<Start>b__3() in c:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src
\SemanticLogging.Etw\TraceEventService.cs:line 149
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.Exception: Reading past end of event
   at Diagnostics.Tracing.TraceEvent.GetUnicodeStringAt(Int32 offset) in c:\Buil
ds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\TraceEven
t.cs:line 1111
   at Diagnostics.Tracing.Parsers.DynamicTraceEventData.PayloadValue(Int32 index
) in c:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2
.7\DynamicTraceEventParser.cs:line 745
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.CreatePayload(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\Blo
cks\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 258
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.CreateEventEntry(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\
Blocks\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 298
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.PreprocessEvent(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\B
locks\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 310
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.<Start>b__1(TraceEvent traceEvent) in c:\Builds\71\EntLib\SLAB-NuGet\src\Block
s\SemanticLogging\Src\SemanticLogging.Etw\TraceEventService.cs:line 142
   at Diagnostics.Tracing.Parsers.DynamicTraceEventData.Dispatch() in c:\Builds\
71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\DynamicTrace
EventParser.cs:line 714
   at Diagnostics.Tracing.TraceEventDispatcher.Dispatch(TraceEvent anEvent) in c
:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\Tra
ceEvent.cs:line 1716
   at Diagnostics.Tracing.ETWTraceEventSource.RawDispatch(EVENT_RECORD* rawData)
 in c:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.
7\ETWTraceEventSource.cs:line 328
   at Diagnostics.Tracing.Parsers.TraceEventNativeMethods.ProcessTrace(UInt64[]
handleArray, UInt32 handleCount, IntPtr StartTime, IntPtr EndTime)
   at Diagnostics.Tracing.ETWTraceEventSource.Process() in c:\Builds\71\EntLib\S
LAB-NuGet\src\Blocks\SemanticLogging\Src\TraceEvent1.2.7\ETWTraceEventSource.cs:
line 200
   at Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.TraceEventServic
e.<Start>b__3() in c:\Builds\71\EntLib\SLAB-NuGet\src\Blocks\SemanticLogging\Src
\SemanticLogging.Etw\TraceEventService.cs:line 149
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()<---
]
EventName : TraceEventServiceProcessTaskFaultInfo
Timestamp : 2013-03-22T20:20:51.9370582Z

Faulted
Mar 27, 2013 at 1:13 AM
I've resolved this problem by performing an IISRESET, and restarting SemanticLogging-svc.exe, due to the fact that i have an HttpModule calling this particular EventSource.