jonwagner / EventSourceProxy

EventSourceProxy (ESP) is the easiest way to add scalable Event Tracing for Windows (ETW) logging to your .NET program
Other
97 stars 20 forks source link

Latest version throws exception at runtime #39

Closed gsteinbacher closed 9 years ago

gsteinbacher commented 9 years ago

I upgraded to the latest version and got the following exception the first time I reference the singleton.

System.MissingMethodException: No parameterless constructor defined for this object. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNe edSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at System.Linq.Enumerable.WhereSelectListIterator 2.MoveNext() at System.Linq.Buffer 1..ctor(IEnumerable 1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable 1 source) at EventSourceProxy.TypeImplementer.ValidateEventMessage(EventAttribute eventAttribute, MethodInfo method, List 1 parameters) at EventSourceProxy.TypeImplementer.EmitMethodImpl(InvocationContext invocationContext, Int32& eventId, EventKeywords autoKeyword) at EventSourceProxy.TypeImplementer.ImplementType() at EventSourceProxy.EventSourceImplementer.b__1(Type t) at System.Collections.Concurrent.ConcurrentDictionary 2.GetOrAdd(TKey key, Func 2 valueFactory) at EventSourceProxy.EventSourceImplementer.GetEventSource(Type type) at EventSourceProxy.EventSourceImplementer.GetEventSourceAs[T]() at System.Lazy 1.CreateValue() --- End of stack trace from previous location where exception was thrown --- at System.Lazy`1.get_Value() at ArcherTech.Instrumentation.ArcherEventSource.get_Log() in c:\Development\Archer\v5.5.x\ArcherTech\ArcherTech.Instrumentation\MainEventSource.cs:line 21

Line 21 of my MainEventSource is the "get" of this propertly.

public static ArcherEventSource Log { get { return Instance.Value; } }

The Instance variable is defined like this... private static readonly Lazy Instance = new Lazy(EventSourceImplementer.GetEventSourceAs();

I do have a static constructor in my class...

    static ArcherEventSource()
    {
        TraceParameterProvider.Default.ForAnything()
                              .AddContext("Machine", () => Environment.MachineName)
                              .AddContext("OS Version", () => Environment.OSVersion.VersionString);
    }

I rolled back to the previous version and this exception does not occur.

jonwagner commented 9 years ago

This should be fixed in v3.0.6