jlaanstra/Windows.UI.Interactivity — pull request #26 by ismaelhamed (2014-04-27 10:57:35+00:00)
Title: Guard agains NullReference exceptions when EventInfo.AddMethod.Invoke returns null in EventTriggerBase.RegisterEvent.

I'm not sure under what circumstances the MethodBase.Invoke will return null, but it does making the cast to EventRegistrationToken throw:

this.addMethod = dlg => (EventRegistrationToken)@event.AddMethod.Invoke(obj, new object[] { dlg });

Proposed solution:

this.addMethod = dlg =>
{
var result = @event.AddMethod.Invoke(obj, new object[] { dlg });
return result != null ? (EventRegistrationToken)result : default(EventRegistrationToken);
};