protected override IModuleCatalog CreateModuleCatalog()
{
return Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml(new Uri("ModuleCatalog.xaml", UriKind.Relative));
}

.net的背景,就不说了。用这个代码作为开头吧。在Bootstrapper载入部件时需要用到。

ModuleCatalog有很多种方法可以导入,总得来说就是灵活的。但偏偏这种看上去比较酷一点的(没有MyApp.exe.config文件,也不写死在cs代码里),却怎么也调试不出来。报的错误有这几种:

There is currently no moduleTypeLoader in the ModuleManager that can retrieve the specified module

{"“\f”(十六进制值 0x0C)是无效的字符  

The IModuleCatalog is required and cannot be null in order to initialize the modules.  

问题主要出在:

1. Xaml文件中定义的ModuleName与ExportModule的名称不符

2. Xaml文件的编译方式选择不正确

3. 忘了

我项目中通过的几个相关代码和设置如下,环境vs2013,Prism 5 + MEF,wpf。

MuduleCatalog.xaml:

<Modularity:ModuleCatalog xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Modularity="clr-namespace:Microsoft.Practices.Prism.Modularity;assembly=Microsoft.Practices.Prism.Composition">
<Modularity:ModuleInfo Ref="file://XianFeng.Client.Modules.Notify.dll"
ModuleName="NotifyModule"
InitializationMode="WhenAvailable"
ModuleType="XianFeng.Client.Modules.Notify.NotifyModule, XianFeng.Client.Modules.Notify" />
</Modularity:ModuleCatalog>

相应的,xxxNotify.dll中的输出文件NotifyModule.cs:

namespace XianFeng.Client.Modules.Notify
{
[ModuleExport("NotifyModule", typeof(NotifyModule))]
public class NotifyModule : IModule
{
[Import]
public IRegionManager regionManager; public void Initialize()
{
this.regionManager.RegisterViewWithRegion(RegionNames.NotifyRegion, typeof(Views.Notify));
}
}
}

ModuleCatalog.xaml文件的属性:

生成操作是Resource是我自己摸出来的,bing到的一些资料上说的都是老版本的吧,都不对,包括那个Mike Taulty的视频的也不对。

就是这样。

Prism 5 + MEF中的ModuleCatalog.CreateFromXaml问题的更多相关文章

  1. 【转】MEF程序设计指南三:MEF中组合部件(Composable Parts)与契约(Contracts)的基本应用

    按照MEF的约定,任何一个类或者是接口的实现都可以通过[System.ComponentModel.Composition.ExportAttribute] 特性将其定义为组合部件(Composabl ...

  2. 在MEF中实现延迟加载部件(转)

    在MEF的宿主中,当我们通过Import声明导入的对象时,组装(Compose)的时候会创建该对象.例如: interface ILogger    {        void Log(string  ...

  3. 在MEF中实现延迟加载部件

    在MEF的宿主中,当我们通过Import声明导入的对象时,组装(Compose)的时候会创建该对象.例如: interface ILogger    {        void Log(string ...

  4. 在MEF中手动导入依赖的模块

    对于简单的场景来讲,在MEF中导入依赖模块非常简单,只要用ImportAttribute标记依赖的成员,MEF模块会自动找到并创建该模块.但有的时候我们依赖的模块是上下文相关的,此时MEF框架的自动组 ...

  5. 【Prism】MEF版HelloWorld

    引言 Pirsm框架是由微软P & P小组设计的,用于构建组合式的WPF企业级应用,支持两个IOC容器,分别为Unity和MEF.官方地址为http://compositewpf.codepl ...

  6. [Prism框架实用分享]如何在Prism应用程序中使用日志

    前言 在Prism中有关日志的命名空间: Microsoft.Practices.Prism.Logging 在Prism中,你可以使用Prism自带的Logger(比如TextLogger等),也可 ...

  7. 【Prism】MEF版UIComposition

    引言 UIComposition原版Demo在PrismV5的解压包里面.原Demo用了.net4.5版本的DLL,我改成.net4.0的. RegionContext 这个Demo比之前那几个示例大 ...

  8. 【Prism】MEF版EventAggregation

    引言 第三弹是EventAggregation Demo的改造. EventAggregation  EventAggregation事件聚集是Prism框架中的通信实现.它可以在松散的模块或者窗体之 ...

  9. 【Prism】MEF版Commanding

    引言 接下来的是Commanding Demo的改造. DelegateCommand    WPF本身提供了一个RoutedCommand,然而没什么卵用.在Prism框架中提供了个更人性化的ICo ...

随机推荐

  1. HBase1.0以上版本的API改变

    HBase1.0以上版本已经废弃了 HTableInterface,HTable,HBaseAdmin等API的使用,新增了一些API来实现之前的功能: Connectioninterface: Co ...

  2. 学习PHP第一天-----简单登录

    <!DOCTYPE html> <html> <head> <title>初级登录界面</title> </head> < ...

  3. javascrit2.0完全参考手册(第二版) 第2章第4节 基本的数据类型

    每一个变量都有一个确定的类型表明它存储什么样的数据.js基本的数据类型有strings字符串.numbers数字.Booleans布尔类型.字符串是使用双引号或单引号包含的一串字符:数字包括整数或浮点 ...

  4. 【android】新手容易遇到的[error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.]Theme出错的问题

    一.概述 近期刚接手了一个项目,开发工具为eclipse,由于版本较低,且考虑到如果转android studio项目的话,会其他人的维护带来困难,所以想着还是维护项目原来的开发环境吧. 但是导入项目 ...

  5. Mysql bench执行sql语句批量操作数据所遇到的问题

    一.错误 rror Code: 1175. You are using safe update mode and you tried to update a table without a WHERE ...

  6. [LintCode] Flatten Binary Tree to Linked List 将二叉树展开成链表

    Flatten a binary tree to a fake "linked list" in pre-order traversal. Here we use the righ ...

  7. Linux常用命令(持续更新)

    lsb_release -a 查看linux操作系统信息 getconf LONG_BIT 查看linux操作系统位数 useradd [-g groupname] username 创建用户,并指定 ...

  8. 数组API

    1.数组的创建 var arrayObj = new Array();//创建一个默认数组,长度是0 var arrayObj = new Array(size);//创建一个size长度的数组,注意 ...

  9. github标记

    <template> <a href="https://github.com/lmk123/Runner" class="github-corner&q ...

  10. Gruntfile.js

    module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), clea ...