我有一条消息的CompositionException异常:“无法重组类型为'SomeService‘的ComposablePart,因为它处于无效状态。只有在已经完全预览或合成之后,才能重组它。”
异常由以下代码引发:
public class SomeService : ISomeService
{
[Import(typeof(ISomeType))]
public ISomeType SomeType { get; set; }
public SomeService()
{
Container.ComposeParts(this);
}
}但这一切都很好:
public class SomeService : ISomeService
{
[Import(typeof(ISomeType))]
public ISomeType SomeType { get; set; }
public SomeService()
{
this.SomeType = Container.GetExportedValue<ISomeType>();
}
}我在其他地方有这个代码"Container.ComposeParts( this )“,它可以工作,但在这里不行。
在谷歌上搜索“无法重组,因为它处于无效状态”后,我没有发现任何有趣的东西。
这条消息是什么意思?谢谢!
发布于 2010-12-01 00:04:34
这可能是因为您正在从多个线程使用CompositionContainer。你真的要这么做吗?
https://stackoverflow.com/questions/4314141
复制相似问题