wcf - 在 MEF 中执行 GetComponentParts 时出错

标签 wcf mef

在执行 GetComponentParts 时出现以下错误,具体来说,当我在 WCF 应用程序中处理多条消息时以连续循环导入时它会重新生成

The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

1) The composition failed because it did not complete within '100' iterations. This is most likely caused by a cycle in the dependency graph of a part which is marked with a non-shared creation policy.

还有一件事我无法找到 CompositionException.Errors 来找到根本原因。

请建议可能的解决方法,因为我在网上没有得到任何建议的线程...

非常感谢

最佳答案

由于这在大部分时间都有效,因此可能是线程问题破坏了 MEF 的内部状态并导致此错误。

当从多个线程使用 CompositionContainer 时,您需要在将 isThreadSafe 参数设置为 true 的情况下创建它,并避免调用修改可用内容的方法 - 例如 ComposeComposeParts,或 AddExportedValue

可以安全调用的方法是 GetExport 和 SatisfyImports 方法。

关于wcf - 在 MEF 中执行 GetComponentParts 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5699849/

相关文章:

c# - 序列化 JSON 字符串以匹配 WCF 服务函数参数

c# - WCF - 拦截消息并发送自定义响应

c# - 编写 Visual Studio 2010 插件,想在代码编辑器中显示一个像 Resharper 这样的工具箱

c# - 错误 : No exports were found that match the constraint:

c# - 在 Azure 函数应用程序中使用 MEF

c# - 如何在 C# 中将命名空间添加到 soap 信封

asp.net - silverlight 不支持 wsHttpBinding

.net - 断开连接的域客户端上的 SecurityNegotiationException

.net - 从区域中删除 View 时内存泄漏

c# - 基于用户权限的 MEF 组件