使用MEF时出错 [英] Getting Error while using MEF
问题描述
我在使用MEF作为项目的一部分时遇到错误。
可能是什么问题?
构图保持不变。由于以下错误,更改被拒绝:
组合产生单个组合错误。根本原因如下。查看CompositionException.Errors属性以获取更多详细信息。
1)未找到符合约束条件的导出:
ContractName SimpleCalculator3.ICalculator
RequiredTypeIdentity SimpleCalculator3.ICalculator
导致:无法设置导入'SimpleCalculator3.Program.calculator(ContractName =SimpleCalculator3.ICalculator)'部分'SimpleCalculator3.Program'。
元素:SimpleCalculator3.Program.calculator(ContractName =SimpleCalculator3.ICalculator) - > SimpleCalculator3.Program
问题是我有很多部件需要包含在容器中,为此我必须使用ImportMany而不是Import
[ImportMany]
IEnumerable < Lazy< IOperation, IOperationData > 跨度>>操作;
而不是
[导入]
IEnumerable < Lazy< IOperation, IOperationData > >操作;
I am getting below Error while using MEF as a part of my project.
What Could be the issue?
The composition remains unchanged. The changes were rejected because of the following error(s):
The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) No exports were found that match the constraint:
ContractName SimpleCalculator3.ICalculator
RequiredTypeIdentity SimpleCalculator3.ICalculator
Resulting in: Cannot set import 'SimpleCalculator3.Program.calculator (ContractName="SimpleCalculator3.ICalculator")' on part 'SimpleCalculator3.Program'.
Element: SimpleCalculator3.Program.calculator (ContractName="SimpleCalculator3.ICalculator") --> SimpleCalculator3.Program
The Problem was that i had many parts which needs to be included in container and for that I have to use ImportMany instead of Import
[ImportMany] IEnumerable<Lazy<IOperation, IOperationData>> operations;
instead of
[Import] IEnumerable<Lazy<IOperation, IOperationData>> operations;
这篇关于使用MEF时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!