MethodInfo.Invoke Works only in Debug Mode for Prism EventAggregator
I have a extension method for Prism's EventAgregator to publish an event using reflection. The implementation is as follows:
MethodInfo raiseMethod = typeof(Extensions).GetMethod("Raise", BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(obj.GetType());
raiseMethod.Invoke(null, new object[] {eventAggregator, obj, eventType});
This method calls an extension method which requires a typed parameter. This code, and the eventing work fine, but only in Debug mode. When switching to a Release build the event never arrives at the su开发者_StackOverflow社区bscriber.
I have tried using the optional parameter during subscription keepSubscriberReferenceAlive
but that does not fix the problem.
Any idea on how to fix this issue?
Update I found that the issue is not releated to the above. It seems there is a filter in place which only allowed event from within the same assembly. But this really doesn't explain why the code worked while in debug mode.
精彩评论