C# PRISM 5,事件聚合器丢失订阅

C# PRISM 5,事件聚合器丢失订阅,c#,wpf,mvvm,prism,eventaggregator,C#,Wpf,Mvvm,Prism,Eventaggregator,我试图在shell关闭时使用eventaggregator(Unity容器)触发/发布事件 所以我可以在视图中保存一些设置。问题是,当我退出应用程序时,事件不再有任何订阅者,就好像有什么东西正在清除他们。我不熟悉事件聚合,所以如果这是显而易见的事情,我深表歉意 我已经在我的外壳中完成了这项工作: public Shell(IEventAggregator eventAggregator) { _eventAggregator = eventAggregator;

我试图在shell关闭时使用eventaggregator(Unity容器)触发/发布事件 所以我可以在视图中保存一些设置。问题是,当我退出应用程序时,事件不再有任何订阅者,就好像有什么东西正在清除他们。我不熟悉事件聚合,所以如果这是显而易见的事情,我深表歉意

我已经在我的外壳中完成了这项工作:

    public Shell(IEventAggregator eventAggregator)
    {
        _eventAggregator = eventAggregator;
        InitializeComponent();
    }

    protected override void OnClosing(CancelEventArgs e)
    {

        var theevent =_eventAggregator.GetEvent<ShellClosingEvent>();
        theevent.Publish("closing");

    }
publicshell(IEventAggregator事件聚合器)
{
_eventAggregator=eventAggregator;
初始化组件();
}
关闭时受保护的覆盖无效(CancelEventArgs e)
{
var theevent=_eventAggregator.GetEvent();
事件。发布(“关闭”);
}
我的观点:(我在构造函数中订阅)

eventAggregator.GetEvent().Subscribe((x)=>
{
如果(x!=“关闭”)返回;
使用(var fs=new FileStream(“clientGridSettings.xml”、FileMode.Create、FileAccess.Write))
{
ClientsGrid.SaveCustomizations(fs);
}
});
活动:

public class ShellClosingEvent : PubSubEvent<string>
{
}
公共类ShellClosingEvent:PubSubEvent
{
}

您是否尝试过订阅Ken Subscribe(Action Action,bool keepSubscriberReferenceAlive)可能与或重复?嗨,我尝试过eventAggregator.GetEvent().Subscribe(onClose,true);但在触发my Shell OnClosing时,事件聚合器仍然没有订阅服务器:(
public class ShellClosingEvent : PubSubEvent<string>
{
}