Help with MefLook example

Apr 28, 2011 at 5:32 PM

Hello,

I am trying to learn MEF. I read some of the theory and now I am trying to get one sample exercise to work with MefLook from MEF2, Preview 3. I quickly noticed that the example wasn’t exactly what I was looking for, since I need more of plug-in architecture. The meflook code sample Solution comes with two Projects; one called EmailServices and another called MefLook. I noticed that MefLook had a direct reference to the second EmailServices project (as opposed to being read dynamically from disk).

I embarked on a simple change to separate the interface (IEmailService.cs) into its own project, to then add it as a reference into both the program (MefLook) and the plug-in (EmailService). Unfortunately, 4 hours later, I still cannot get the plug-in architecture to work. MefLook starts, but none of the dependencies are found, resulting in a blank screen.

At one point, I added the EmailServices.dll as a reference (or had MEF scan a folder for it) and I got it to work a little further, but it couldn’t find the other dependencies inside of EmailServices.dll (a file called Data/inbox.xml)

Could someone familiar with the example tell me why my expectations are wrong? Meanwhile, I am moving to the MefStudio exercise to see if I can learn anything from that.

 

A first chance exception of type 'System.ComponentModel.Composition.ImportCardinalityMismatchException' occurred in System.ComponentModel.Composition.Codeplex.dll

A first chance exception of type 'System.ComponentModel.Composition.ChangeRejectedException' occurred in System.ComponentModel.Composition.Codeplex.dll

System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'MeflookSample.MessageList' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

 

1) No exports were found that match the constraint:

                ContractName  frankInter.IEmailService

                RequiredTypeIdentity   frankInter.IEmailService

 

Resulting in: Cannot set import 'MeflookSample.MessageList.emailService (ContractName="frankInter.IEmailService")' on part 'MeflookSample.MessageList'.

Element: MeflookSample.MessageList.emailService (ContractName="frankInter.IEmailService") --> MeflookSample.MessageList --> AssemblyCatalog (Assembly="Meflook, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")

 

A first chance exception of type 'System.ComponentModel.Composition.ImportCardinalityMismatchException' occurred in System.ComponentModel.Composition.Codeplex.dll

A first chance exception of type 'System.ComponentModel.Composition.ChangeRejectedException' occurred in System.ComponentModel.Composition.Codeplex.dll

A first chance exception of type 'System.ComponentModel.Composition.ImportCardinalityMismatchException' occurred in System.ComponentModel.Composition.Codeplex.dll

A first chance exception of type 'System.ComponentModel.Composition.ChangeRejectedException' occurred in System.ComponentModel.Composition.Codeplex.dll

System.ComponentModel.Composition Warning: 1 : The ComposablePartDefinition 'MeflookSample.LeftSpine' has been rejected. The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.

 

1) No exports were found that match the constraint:

                ContractName  MeflookSample.FolderView

                RequiredTypeIdentity   MeflookSample.FolderView

 

Resulting in: Cannot set import 'MeflookSample.LeftSpine.fv (ContractName="MeflookSample.FolderView")' on part 'MeflookSample.LeftSpine'.

Element: MeflookSample.LeftSpine.fv (ContractName="MeflookSample.FolderView") --> MeflookSample.LeftSpine --> AssemblyCatalog (Assembly="Meflook, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")