首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

Prism . MEF的有关问题?无法ModuleManage.Load成功

2012-05-29 
Prism . MEF的问题?无法ModuleManage.Load成功请教下各位mef的问题。现按照prism安装中提供的 mef源码。 然

Prism . MEF的问题?无法ModuleManage.Load成功
请教下各位mef的问题。

现按照prism安装中提供的 mef源码。 然后在上面再增加一个项目做验证熟悉。

现在问题来了。我新增的项目总是无法总过IModuleManage.load来加载。

首先我说下我的步骤。我先新建一个SystemManage的应用程序项目。

删除Appl.xaml文件。新增SystemManage类,实现IModule接口代码如下:

[ModuleExport(typeof(SystemManage), InitializationMode = InitializationMode.OnDemand)]
  public class SystemManage : IModule
  {
  [Import]
  public IRegionManager regionManager;
  /// <summary>
  /// Notifies the module that it has be initialized.
  /// </summary>
  public void Initialize()
  {
  this.regionManager.RegisterViewWithRegion("MainContentRegion", typeof(MainPage));
  }
  }
 然后在systemManage项目中的MainPage.xaml中增加[Export]标记 ,
然后在Shell中增加一个Content控件注册一个MainContentRegion的(用于显示systemmanage中的页面),配置ModuleCatalog,新增<Modularity:ModuleInfo Ref="SystemManage.xap" InitializationMode="OnDemand" ModuleName="SystemManage" ModuleType="SystemManage.SystemManage, SystemManage, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
做完以上步骤之后,增加一个按钮去调用SystemManage模块,但是无法IModuleManage.load成功。
要是我将次页面增加到自带源码的部分,又可以成功。
请问下,哪位使用过mef这个框架。或者能给一个简单的例子也可以,使用时还要注意哪些方面?多谢


[解决办法]
闲着也是闲着,我把步骤贴出来吧。尽可能详细些。

1、New-Project-LoadModuleTest.Main

1)把MainPage.xaml->Shell.xaml, 并Refactor一下。





引用四个DLL:


Shell用[Export]修饰一下:

C# code
using System.Windows.Controls;using System.ComponentModel.Composition;namespace LoadModuleTest.Main{    [Export]    public partial class Shell : UserControl    {        public Shell()        {            InitializeComponent();        }    }} 

热点排行