在vshost外部运行时,MAF AddIn进程退出

时间:2013-06-24 11:55:03

标签: c# .net maf vshost.exe

我有一个MAF AddIn,所以我可以从WPF应用程序显示Windows窗体应用程序。 当在vshost中从Visual Studio运行时,它完全可以正常运行但是当我在VS外部运行应用程序时,大多数时候AddIn进程退出:

    public FrameworkElement GetAddInUI(bool recoverLayout)
    {            
        DC.Resolve<ILogger>().Info("GetAddInUI...");
        // the process exits here when not in VS
        INativeHandleContract inhc = scpAddInContract.GetAddInUI(recoverLayout);
        DC.Resolve<ILogger>().Info("GetAddInUI done.");
        FrameworkElement fe = null;
        DC.Resolve<ILogger>().Info("ContractToViewAdapter...");
        DC.Resolve<ISynchronizationService>().Invoke(() =>
        {
            fe = FrameworkElementAdapters.ContractToViewAdapter(inhc);                
        });

        DC.Resolve<ILogger>().Info("ContractToViewAdapter done");

        return fe;
    }

    public INativeHandleContract GetAddInUI(bool recoverLayout)
    {
        INativeHandleContract value = null;
        dispatcher.DoWork(() => value = new IMyNativeHandle(FrameworkElementAdapters.ViewToContractAdapter(scpAddInView.GetAddInUI(recoverLayout))));

        return value;
    }

您是否有使用MAF的经验,并且可以解释在vshost下运行它会产生什么样的差异?

0 个答案:

没有答案