how to debug MEF exception?

后端 未结 2 1224
执念已碎
执念已碎 2021-01-18 20:05

we are currently using MEF (Managed Extensibility Framework, http://mef.codeplex.com/ ) and it throws out exceptions, with limited information to proceed on.

is ther

2条回答
  •  再見小時候
    2021-01-18 20:21

    I feel your pain. When I'm stuck, I typically dump the MEF composition information to get more information on the cause of the composition failure. For instructions on how to do this, see Diagnosing Composition Problems in the MEF Programming Guide or the Debugging MEF topic on MSDN.

    In .NET 4.5 (or the current MEF 2 preview 4 release available on codeplex) there is a simpler option: you can improve the usefulness of the error message by disabling silent rejection in the CompositionOptions which you pass to the container constructor.

    edit: ah, you're getting a ReflectionTypeLoadException. That's another matter: it means that the types in some assembly cannot be successfully loaded, typically because they reference other types that cannot be found. In your code example, you should be able to reproduce the problem by invoking assembly.GetTypes(), without involving MEF.

提交回复
热议问题