Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KernelTraceEventParser.All generates System.InvalidCastException #29

Open
markculley opened this issue Nov 3, 2015 · 0 comments
Open

Comments

@markculley
Copy link

The exception occurs on the .NET 3.5 runtime but not the .NET 4.0+ runtime, when executing the line "source.Kernel.All += Print;" in the sample code, below. Neither the same code nor my code doing something very similar work.

static void DataProcessing(string dataFileName)
    {
        Out.WriteLine("Opening the output file and printing the results.");
        using (var source = new ETWTraceEventSource(dataFileName))
        {
            if (source.EventsLost != 0)
                Out.WriteLine("WARNING: there were {0} lost events", source.EventsLost);

            // Set up callbacks to 
            source.Clr.All += Print;
            source.Kernel.All += Print;
        ...

Here is the Exception:

System.InvalidCastException occurred
Message=Unable to cast object of type 'System.Action1[Microsoft.Diagnostics.Tracing.TraceEvent]' to type 'System.Action1[Microsoft.Diagnostics.Tracing.Parsers.Kernel.EventTraceHeaderTraceData]'.
Source=Microsoft.Diagnostics.Tracing.TraceEvent
StackTrace:
at Microsoft.Diagnostics.Tracing.Parsers.Kernel.EventTraceHeaderTraceData.set_Target(Delegate value)
at Microsoft.Diagnostics.Tracing.TraceEventParser.Subscribe(SubscriptionRequest cur, TraceEvent template, Object templateState, Boolean mayHaveExistedBefore)
at Microsoft.Diagnostics.Tracing.TraceEventParser.<>c__DisplayClassb.b__a(TraceEvent template)
at Microsoft.Diagnostics.Tracing.Parsers.KernelTraceEventParser.EnumerateTemplates(Func3 eventsToObserve, Action1 callback)
at WindowsEtwDataCollector.EtwDataCollector.RunKernelTrace(ConditionChecker shouldAbort) in C:\dev\vault\Vault\DataCollectors\WindowsEtwDataCollector\EtwDataCollector.cs:line 174
InnerException:

Microsoft.Diagnostics.Tracing.Parsers.Kernel.EventTraceHeaderTraceData
.. is derived from ...
Microsoft.Diagnostics.Tracing.TraceEvent

System.InvalidCastException occurred
Message=Unable to cast object of type 'System.Action1[Microsoft.Diagnostics.Tracing.TraceEvent]' to type 'System.Action1[Microsoft.Diagnostics.Tracing.Parsers.Kernel.EventTraceHeaderTraceData]'.
Source=Microsoft.Diagnostics.Tracing.TraceEvent
StackTrace:
at Microsoft.Diagnostics.Tracing.Parsers.Kernel.EventTraceHeaderTraceData.set_Target(Delegate value)
at Microsoft.Diagnostics.Tracing.TraceEventParser.Subscribe(SubscriptionRequest cur, TraceEvent template, Object templateState, Boolean mayHaveExistedBefore)
at Microsoft.Diagnostics.Tracing.TraceEventParser.<>c__DisplayClassb.b__a(TraceEvent template)
at Microsoft.Diagnostics.Tracing.Parsers.KernelTraceEventParser.EnumerateTemplates(Func3 eventsToObserve, Action1 callback)
at WindowsEtwDataCollector.EtwDataCollector.RunKernelTrace(ConditionChecker shouldAbort) in C:\dev\vault\Vault\DataCollectors\WindowsEtwDataCollector\EtwDataCollector.cs:line 174
InnerException:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant