Finally I was able to trace the issue why my In-Proc EventListener's OnEventWritten was not being called. In order to understand it let's create a sample console application targeting .net framework 4.5.
Let's add a simple method to write event when a request is received for password hashing. It has an EventId set as 1.
Now add an event listener as follows:
Now let's first enable the events for the listener after instantiating this. We can now call the EventSource method to write event data. When we run this EventListener's OnEventSourceCreated does get called but there is never a call for OnEventWritten when the event data is written. If we set a breakpoint there, it never gets hit.
Now let's change the code a little and remove the keyword detail decoration from the EventSource's method as follows:
Without changing anything else, let's run the application again. Now we notice that the break point in MyEventListener.OnEventWritten does get hit.
I have logged an issue here on Connect. Let's see if we are missing something here:
In order to enable events by the listener, we need to be clearly specifying the keywords we are interested in. There can be more than one keywords used with bit masking (that's why the keywords should have enumeration values in the power of 2). We can also enable the listener for all keywords using Keywords.All. [Thanks, Alex Ghiondea!]