The code below shows how to reproduce this error.
To test, make sure you are compiling with .NET 4.5 and add the MEF assemblies:
- System.ComponentModel.Composition
- System.ComponentModel.Composition.Registration
The problem is that MEF wants to build a Person object, but it cannot complete its property injection for "Age" (which is marked as "Import").
To reproduce the error, comment out the line marked below.
using System; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; using System.Reflection; namespace ForStackOverflow { public class Program { public static void Main(string[] args) { var container = new CompositionContainer( new AssemblyCatalog(Assembly.GetExecutingAssembly()));
source share