I'm trying to match imports and exports with mefx, using /exports and /imports.
I get missing imports in this situation:
Let's demonstrate with the most simple expample ever
namespace Example01
{
publicclassProgram
{
publicclass MyClass
{
[Import("MajorRevision")]
publicint
MajorRevision { get;set; }
}
publicclassMyExportClass
{
[Export("MajorRevision")]//This one will match.
publicintMajorRevision = 4;
[Export("MinorRevision")]
publicintMinorRevision = 16;
}
}
}
Running my mefx commands gives these results
mefx /dir:Example01\bin\Debug /parts
Example01.MyExportClass
mefx /dir:Example01\bin\Debug /exports
MajorRevision : System.Int32
MinorRevision : System.Int32
mefx /dir:Example01\bin\Debug /imports
I get an empty line for "imports". Looking on internet for such problem, I found this article:
http://stackoverflow.com/questions/7810661/mefx-does-not-list-an-importer
But the response doesn't satisfy me. It's sayed "how", but not "why". I'm certainly missing something.
I tried what was explained doing this:
[Export]
publicclassMyClass
{
[Import("MajorRevision")]
publicint
MajorRevision { get;set; }
}
Now I get this result with mefx:
mefx /dir:Example01\bin\Debug /imports
MajorRevision : System.Int32.
I would expect this result without the export clause on MyClass. My application is resolving perfectly the parts without this "Export". It's not necessary. Why mefx needs this to see the import? I'm not ready to add unnecessary information in my code just for mefx.