PRISM 4 - RegisterViewWithRegion & Custom Export Attributes
|
I am using Prism 4 with MEF Extensions and the MVVM pattern. During initialization in a module I call RegisterViewWithRegion(RegionNames.MyRegion, typeof(MyView)) which works perfectly when the view is constructed like this:
The view gets registered and everything is fine. As soon as I change the Export to a Custom Export Attribute the view can't be found anymore, although it is still in the container. This Custom Export Attribute is taken from the Stock Trader RI:
and the interface is
By changing the Export Attribute to
when calling RegisterViewWithRegion it throws an error: Activation error occured while trying to get instance of type MyView, key "" Any advice? I was looking at this part of code the whole day without finding a solution. |
|||||
|
|
Another day, another way... I will try to answer my question even though I have only limited knowledge about PRISM. In other words: I'm still learning. The Custom Export Attribute taken from the Stock Trade RI is used by the
But I think when using ViewInjection and Prism Navigation it is better to just use the default [Export] attribute, then everything works smoothly. |
|||
|
Are you configuring the aggregate catalog in your MEF bootstrapper? If so, are you adding the assembly that contains your ViewExportAttribute and AutoPopulateExportedViewsBehavior classes? I believe this happens in the StockTraderRI's bootstrapper with this line:
The StockTraderRICommands class is in the same assembly as the ViewExportAttribute and AutoPopulateExportedViewsBehavior classes. |
|||||
|
|
The custom export attribute passes As far as the activation error you'll need to look at the exception in more detail. The root cause is probably there somewhere, perhaps buried under an InnerException. |
|||
|
I encountered exactly the same problem and it was a hard one for a MEF/PRISM beginner. okieh describes the problem very well, I just want to post an alternative solution, coming from theStocktraderUI sample application: The solution works (/seems to work) if you want View discovery without any form of config file, etc. where you have to register your views. 1. Modify the
The [Export] attribute is added and the base constructor is now called with 2. Modify
The That's basically it. You can use the This way, you don't need additional interfaces for your views and can still discover everything without hardcoded registration. I hope it helps and let me know, if I missed any drawbacks of my solution. http://stackoverflow.com/questions/6271167/prism-4-registerviewwithregion-custom-export-attributes |
PRISM 4 - RegisterViewWithRegion & Custom Export Attributes的更多相关文章
- [转]How do you create a custom AuthorizeAttribute in ASP.NET Core?
问: I'm trying to make a custom authorization attribute in ASP.NET Core. In previous versions it was ...
- jquery 使用attr() 函数对复选框无效的原因,javascript那些事儿——properties和attributes
复选框是网站开发的时候经常用到的网页标签之一,常见的在页面上对复选框的操作包括取值和修改复选框的状态.在jquery中,常见的操作标签的值得函数为attr,然而在操作复选框的时候,通常采用的却是pro ...
- Advanced Pricing - How to source Pricing Attributes using QP_CUSTOM_SOURCE.Get_Custom_Attribute_Valu
详细内容需要参考文档:Oracle 11i Advanced Pricing-Don't Customize, Extend! utl:http://blog.csdn.net/cai_xingyun ...
- [翻译]NUnit---Property and Random Attributes(十四)
小记:由于工作琐碎,没得心情翻译而且也在看<CLR vis C#>,所以断更了差不多5个月,现在继续翻译,保证会翻译完成,不会虎头蛇尾. 另:NUnit已经更新到2.6.3版本,虽然正在开 ...
- Collection View Programming Guide for iOS---(七)---Custom Layouts: A Worked Example
Custom Layouts: A Worked Example Creating a custom collection view layout is simple with straightfor ...
- Platform Invoke
PInvoke 允许managed code 来调用在DLL中实施的unmanged function. Platform invoke relies on metadata to locate ex ...
- configure.ac
# # Copyright (C) - Tobias Brunner # Copyright (C) - Andreas Steffen # Copyright (C) - Martin Willi ...
- CentOS7.2非HA分布式部署Openstack Pike版 (实验)
部署环境 一.组网拓扑 二.设备配置 笔记本:联想L440处理器:i3-4000M 2.40GHz内存:12G虚拟机软件:VMware® Workstation 12 Pro(12.5.2 build ...
- 所有selenium相关的库
通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml im ...
随机推荐
- linux命令详解——umask
当我们登录系统之后创建一个文件总是有一个默认权限的,那么这个权限是怎么来的呢?这就是umask干的事情.umask设置了用户创建文件的默认 权限,它与chmod的效果刚好相反,umask设置的是权限& ...
- deep_learning_Function_bath_normalization()
关于归一化的讲解的博客——[深度学习]Batch Normalization(批归一化) tensorflow实现代码在这个博客——[超分辨率]TensorFlow中批归一化的实现——tf.layer ...
- maven 学习之路一
一.mave介绍: maven :我的理解就是一个代码构建管理的一个工具.类似的工具有gradle,ant等. 官方理解:Apache Maven is a software project mana ...
- 隔离技术线程池(ThreadPool)和信号量(semaphore)
一.首先要明白Semaphore和线程池各自是干什么? 信号量Semaphore是一个并发工具类,用来控制可同时并发的线程数,其内部维护了一组虚拟许可,通过构造器指定许可的数量,每次线程执行操作时先通 ...
- ibatis与mybatis的区别
一.最主要的区别就是mybatis简化了编码的过程,不需要去写dao的实现类,直接写一个dao的借口,再写一个xml配置文件,整个mybatis就配置好了,也就是数据库就连接好了,然后再service ...
- Linux文件类型和文件相关命令
文件类型 ll后可以看到文件详情: -:常规文件(内部类型是什么,用file命令) d:directory,目录文件 b:blobk device,块设备文件,支持以“block”为单位进行随机访问 ...
- sparkStreaming(2.1.0)示范代码
package cn.piesat import org.apache.spark.SparkConfimport org.apache.spark.sql.SparkSessionimport or ...
- python selenium 笔记
1.安装环境 下载python 3.6.4 第一页把最下面的环境变量勾上.第二页把 all user 勾上 直接安装到下一步 安装完成之后 cmd直接输入python 可以看到版本 2.安装 ...
- Visual Studio下__cplusplus宏为199711L的问题
Visual Studio下__cplusplus宏为199711L的问题 / Zc:__ cplusplus(启用更新的__cplusplus宏) 该/ ZC:__ CPLUSPLUS编译器选项使_ ...
- Eclipse 开发环境修改及MAVEN配置
Eclipse集成Maven配置 默认为 修改为所用版本 选择maven软件所在目录 勾选 默认连接仓库为 修改为