none
Event Source: An item with the same key has already been added RRS feed

  • General discussion

  • Im trying to use new semantic application block for logging. As per MSDN i have test method which inspects the EventSource using

    EventSourceAnalyzer.InspectAll(MyEventSource.Log);

    But when i run this test i'm getting error

    An item with the same key has already been added 
    

    Usually we get this error if we use same event id, but im using different EventID for each method. Below is my event source class

    [EventSource(Name = "SLAB_1.1.1403.1")]
    public class MyEventSource : EventSource
    {
        public class Keywords
        {
            public const EventKeywords Page = (EventKeywords)1;
            public const EventKeywords DataBase = (EventKeywords)2;
            public const EventKeywords Diagnostic = (EventKeywords)4;
            public const EventKeywords Perf = (EventKeywords)8;
        }
    
        public class Tasks
        {
            public const EventTask Page = (EventTask)1;
            public const EventTask DBQuery = (EventTask)2;
        }
    
        private static MyEventSource _log = new MyEventSource();
        private MyEventSource() { }
        public static MyEventSource Log { get { return _log; } }
    
        [Event(1, Message = "Application Failure: {0}",
        Level = EventLevel.Critical, Keywords = Keywords.Diagnostic)]
        internal void Failure(string message)
        {
            if (this.IsEnabled(EventLevel.Critical, Keywords.Diagnostic))
            {
                this.WriteEvent(1, message);
            }
        }
    
        [Event(2, Message = "Application Failure1: {0}",
        Level = EventLevel.Critical, Keywords = Keywords.Diagnostic)]
        internal void Failure(string message, string exception)
        {
            if (this.IsEnabled(EventLevel.Critical, Keywords.Diagnostic))
            {
                this.WriteEvent(2, message, exception);
            }
        }
    
        [NonEvent]
        internal void Failure(string message, Exception ex)
        {
            if (this.IsEnabled(EventLevel.Critical, Keywords.Diagnostic))
            {
                Failure(message, ex.ToString());
            }
        }
    }


    Wednesday, April 2, 2014 4:21 PM

All replies

  • Hi Lax,

    See the following ink for details. http://entlib.codeplex.com/discussions/435385

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 3, 2014 7:09 AM
    Moderator
  • Thanks wong, but the issue in that article you mentioned was using same EventId for two different function. I'm using two different EventIds for two different functions. but my function names are same (overloaded), if that make any difference
    Thursday, April 3, 2014 10:08 PM
  • Hi Lax,

    Try to comment the overloaded method, clean and rebuild you project and try again. I think ETW maybe use different algorithm about this problem.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 9, 2014 8:04 AM
    Moderator