0

使用 Prism Scultpure 我正面临这个问题

有人可以帮我做什么。我有 R1 区域,但它会引发以下错误

以下代码中的粗体行是错误

public virtual void StartAction()
        {
            global::System.ComponentModel.BackgroundWorker backgroundWorker = new global::System.ComponentModel.BackgroundWorker();
            backgroundWorker.WorkerReportsProgress = true;
            backgroundWorker.DoWork += new global::System.ComponentModel.DoWorkEventHandler(this.StartActionWorker);
            backgroundWorker.RunWorkerAsync();
            CandidateView candidateView = null;
            foreach (object view in **this.RegionManager.Regions["R1"].Views**)
            {
                if (true == view is CandidateView)
                {
                    candidateView = view as CandidateView;
                    break;
                }
            }

            if (null == candidateView)
            {
                candidateView = this.Container.GetExportedValue<CandidateView>();
                this.RegionManager.Regions["R1"].Add(candidateView);
            }

            this.RegionManager.Regions["R1"].Activate(candidateView);
        }

合成产生了一个单一的合成错误。下面提供了根本原因。查看 CompositionException.Errors 属性以获取更多详细信息。1) 区域管理器不包含 R1 区域。导致:初始化模块“CandidateMModule”时发生异常。- 异常消息是:区域管理器不包含 R1 区域。- 试图从中加载模块的程序集是:Candidate,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null 检查异常的 InnerException 属性以获取更多信息。如果在 DI 容器中创建对象时发生异常,您可以通过 exception.GetRootException() 来帮助定位问题的根本原因。导致:在类型“Microsoft”上调用“OnImportsSatisfied”方法时发生异常。实践.Prism.MefExtensions.Modularity.MefModuleManager'。导致:无法激活部件“Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager”。元素:Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager --> Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager --> AssemblyCatalog (Assembly="Microsoft.Practices.Prism.MefExtensions, Version=4.0.0.0, Culture =neutral, PublicKeyToken=31bf3856ad364e35") 导致:无法从“Microsoft.Practices.Prism”部分导出“Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager (ContractName="Microsoft.Practices.Prism.Modularity.IModuleManager")” .MefExtensions.Modularity.MefModuleManager'。元素:Microsoft.Practices.Prism.MefExtensions.Modularity.MefModuleManager (ContractName="

4

1 回答 1

0

您可能正试图在加载之前填充该区域。检查区域是否已注册RegionManager.Regions.ContainsRegionWithName("R1")

于 2011-03-22T08:36:30.420 回答