Invalid exports - EXCEPTION

Jul 13, 2011 at 9:12 AM

Hi All,

I am new to WAF, it's really interesting to work with. Today I have encountered an issue while doing an export please find the code where my issue pops up. 

MyController dtController = Container.GetExportedValue<MyController >(); 

I tried to debug with "mef.exe", but i was not able to get FIX the issue with the information provided by the "mef.exe" 

Error message :

No valid exports were found that match the constraint '((exportDefinition.ContractName == ("Data.Applications.Controllers.MyController ") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "Data.Applications.Controllers.MyController".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))', invalid exports may have been rejected.



Jul 16, 2011 at 7:32 PM

Hi Jack,

This exception is thrown by MEF when the MyController has defined “imports” which cannot be found or are invalid. Please note that this works recursive. The error might be in a type that’s imported by another imported type and not the MyController itself.

Please check:

  1. Have all imported types the Export Attribute with the correct type definition?
  2. Have all exported types the ImportConstructor Attribute attached when constructor injection is used?

I hope this helps.

Aug 8, 2011 at 2:53 PM
Edited Aug 8, 2011 at 3:00 PM

Jbe thanks for your help, but I am facing the problem still, Please find the senario/code

Code in Presentation layer:

public partial class StudListView : UserControl, IStudentListView

Code in StudentController:

public class StudentController

public StudentController(CompositionContainer container, ShellViewModel shellViewModel, StudentViewModel StudentViewModel)

Code in Application Controller:

public class ApplicationController : Controller {

private readonly StudentController _studentController;

public ApplicationController(IMessageService messageService,IPresentationService presentationService,IEntityController entityController,UserController userController,StudentController studentController ,ShellViewModel shellViewModel)


While i am trying to do a export by the below code i am getting the error.

IStudentListView stdListView = container.GetExportedValue<IStudentListView>();

studentListViewModel =new StudentListViewModel (stdListView , entityService.Patients) 

It would be great if you could help me in come out this BIG  HURDLE....






Aug 9, 2011 at 1:51 AM

Hi Jack,

After review your source code, I think that has no problem with statement takes IStudentListView object.

You should check the initialization of the class StudentController , because I think your class StudentControlleris declared Imported type, which means that MEF is automatically initialized when the application starts by class ApplicationController. Thus the initialization of class StudentListViewModel, You have to declare are the Imported type:

public StudentListViewModel(IStudentListView stdListView,xxxx ....l):base(stdListView){}

I hope this helps.


Aug 9, 2011 at 6:52 AM

Thanks for the Interest you have shown to my problem. I am facing this issue only in unti test. It works fine in my core project...

I don't have any idea about Y it is behaving differently in different places….

This is really very strange to me

Any  Help ?