开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜