How to recomposit empty DirectoryCatalog for MEF in WPF

懵懂的女人 提交于 2019-12-06 09:55:47

Refreshing the DirectoryCatalog triggers a recomposition. An import on a MEF part can only be recomposed if it is explicitly marked as such, for example like this:

[ImportMany(typeof(IFoo),AllowRecomposition=true)]
IEnumerable<IFoo> Foos { private get; set; }

If an import is affected by the recomposition, but it isn't marked with AllowRecomposition=true, then you get an error: "Change in exports prevented by non-recomposable import".

Also, imports via a constructor don't support recomposition at all. However, you can work around this.

Bassi

Whenever there is error like :

"Activation error occurred while trying to get instance of type , key "" "

Then please check whether [Export] attribute is specified in <User Control page> that we are going to inject in Region.

It is small thing but can waste you hours in debugging!

Thanks! Bassi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!