Dec 31, 2009 at 10:40 PM
Edited Dec 31, 2009 at 10:46 PM
I've recently started a mid-size project using MEF, and in general I'm impressed with the approach taken and it's ease of use - but having the odd issue here and there...
One item has me confused however: I accidentally forgot to export a class - generally no big deal, however the error message is surprisingly garbled and confusing:
"no valid exports were found that match the constraint '((exportDefinition.ContractName="Shell.MainShell") && (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity)..."
(thrown from ExportProvider.cs, line 108)
The main class (Mainshell) was correct - but nowhere in the message does it mention the actual import that's unsatisfied (ExportTypeIdentity has nothing to do with my class), leaving me dazed and confused as to where to look to fix the problem.
I believe that the correct message should be something similar to:
"The import 'IMenuButton MyMenu' in class Shell.Mainshell (line number?) can't be found
Too many exports
The error message for too many items appears to be identical. There's a switch option for 'too many items' in the ExportProvider code - however it doesn't appear to be activated correctly. In short, the same "no valid exports were found"
message appears. In this case I think a more meaningful message would be:
"There are too many exports for 'IMenuButton MyMenu' in class Shell.Mainshell (line number?). Exports are:
* class / export
* class / export (etc)"
Some improved error handling would make my New Years day morning that much more satistfying... ! (HNY, MX to all!)