I can’t solve what seems to be the main problem of MEF: I have a “plugins” project (which we will call P1 and P2), and a third project that is common to both plugins (which we will call C). P1 and P2, as reference C.
When you try to import a component that lives in P1, it fails because this component has dependencies on components that live in C.
Here is the trace:
System.ComponentModel.Composition Warning: 1: ComposablePartDefinition 'MyCompany.Client.Pms.Plugin.InclusionList.ViewModel.InclusionListViewModel' was rejected. The composition remains unchanged. Changes were rejected due to the following error (s): the composition produced multiple composition errors with four root causes. The main reasons are as follows. See the CompositionException.Errors property for more information.
1) Export was not found, which corresponds to the restriction '((exportDefinition.ContractName = "MyCompany.Client.Plugins.Common.Controls.Selectors.PortfolioSelectors.ViewModel.ICalypsoBookSelectorViewModel") && & && & & &; (exportDefinition.Metadata.Metadata.Meteyata.Metadata.Meteyata.Meteyata.Meteyata.Meteyata.Meteyata.Meteyata.Meteyata.Meteyata. "ExportTypeIdentity") && & && & &&&&& "MyCompany.Client.Plugins.Common.Controls.Selectors.PortfolioSelectors.ViewModel.ICalypsoBookSelectorViewModel" .Equals (exportDefinition.Metadata.get_Item) "ExportType)
Result: Unable to install import. MyCompany.Client.Pms.Plugin.InclusionList.ViewModel.InclusionListViewModel.CalypsoBookSelectorViewModel (ContractName = "MyCompany.Client.Plugins.Common.Controls.Selectors.PortfolioSelectors.ViewModel.ICalypsoBooklmsPlomPlsBooksmslmspartlemslemspemsplsbooksmslsmslsplsbooksmslsmslsplsbooksmslsmslsmslsplsbooksmslemsplsbooksmslsmsmsplsbooksmslsmslsmslsmslsmslsmslsmslsmslsmsmslsmslsmslsmslslsmslsmslsmslsmsmslsmslsmslslsmslsmslsmsmsls InclusionList.ViewModel.InclusionListViewModel '. Element: MyCompany.Client.Pms.Plugin.InclusionList.ViewModel.InclusionListViewModel.CalypsoBookSelectorViewModel (ContractName = "MyCompany.Client.Plugins.Common.Controls.Selectors.PortfolioSelectors.ViewModel.ICalypsoBookMentlCommsPlomBooksComPlomBooksComPlientBook .ViewModel.InclusionListViewModel → DirectoryCatalog (Path = "C: \ Work \ mmtrader \ dashboard \ Code \ Src \ Dashboard \ MM \ Trader \ bin \ Debug \ Plugins \ Positions")
[...] (Three other problems are exactly the same on different viewing models)
I looked at the MEF directory and it turns out that MEF knows about these view models, so I don’t know what is missing.
As Dennis requested below, here is my import / export:
Export
Export(typeof(ICalypsoBookSelectorViewModel))] public class CalypsoBookSelectorViewModel : ScreenWithCleanupLifecycle, ICalypsoBookSelectorViewModel {...}
Import
[Import(typeof(ICalypsoBookSelectorViewModel))] public ICalypsoBookSelectorViewModel CalypsoBookSelectorViewModel { get; set; }
And the directory:

Thanks in advance for your help!
c # composition mef
Antoine jaussoin
source share