如何对 mef 中的双重加载对象进行故障排除
我遇到的问题是我的对象在 MEF 中加载了两次。因此 MEF 返回了我的两个对象,这导致我的整个程序崩溃,因为我只期望一个。
如何跟踪/单步执行我的程序以找出对象被双重注册的位置?
我的班级有一个导出标签。我认为这就是其中之一。
我正在使用棱镜,出现两次的对象是壳视图。
TDL 无法弄清楚如何调试 mef
I have an issue where my object is loaded twice in MEF. So MEF returns two of my object, which causes my entire program to crash because I am expecting only one.
How can I trace through/step through my program to figure out where the objects are being double registered?
I have an Export tag on the class. I assume this accounts for one of the instances.
I am using prism and the object that appears twice is the Shell view.
TDL having trouble figuring out how to debug mef
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您组合对象时,MEF 将引发 CompositionException 当它尝试组成与类型匹配的
[Import]
时。 CompositionException 的异常详细信息非常详细,将为您提供潜在的匹配项。查看 CompositionException 的全文 - 它应该为您提供给定导入发生的所有“匹配”,以便您调试问题。
When you compose the object, MEF will raise a CompositionException when it tries to compose the
[Import]
matching the type. The exception details of the CompositionException are very detailed, and will give you the potential matches.Look at the full text of the CompositionException - it should provide you with all of the "matches" that are occurring for a given import, allowing you to debug the issue.
我敢说您以某种方式将程序集两次加载到 AggregateCatalog 中。
I'd venture to say you loaded the Assembly twice into the AggregateCatalog somehow.