I accidentally changed the following code:
[ImportMany] private List<IMessageSender> MessageSenders { get; set; }
to
[ImportMany] private IEnumerable<IMessageSender> MessageSenders { get; set; }
And he solves the problem.
But still, why? Not List<T> a IEnumerable<T> ?
ADD
And even a stranger, I changed IEnumerable to IList, it works. Why?
Possible explanation
(I would like to share my explanation with this.)
The following interface may produce exactly the same error.
interface IMyList<T> : IList<T> { } [System.Composition.ImportMany] // MEF 2 private IMyList<IMessageSender> MessageSenders { get; set; }
This source of MEF 2 shows the reason.

The Equals () method of 3 SupportedContactTypes returns false with IMyList <>. Therefore, in MEF2 will not return a valid export for IMyList <>. And MEF 2 does not have a default value for a property decorated with the [ImportMany] attribute. Thus, in the following logic, the exception related to the dependency will be ignored.

So, we can say that the ImportMany attribute only supports an array and 3 supported generic types.
source share