dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.55k stars 4.54k forks source link

Question: Manual Plugin Instantiation in MEF #27884

Open rjperes opened 5 years ago

rjperes commented 5 years ago

Is it possible to do manual instantiation of discovered plugins with MEF? If so, where can I find some more information? To be clear, I would like that plugins instantiated by the CompositionContext.GetExports method be instantiated by myself.

Thanks!

rjperes commented 5 years ago

Hello? Anybody home?

richlander commented 5 years ago

What does it mean to instantiate the plugins? Are there some docs you can point me to that explain that?

rjperes commented 5 years ago

When GetExports is called, does it not instantiate any components/plugins/parts/whateveryouwanttocallit? What does it use - Activator.CreateInstance, ConstructorInfo.Invoke, or what? What I'm asking is, how can I replace this behavior.

richlander commented 5 years ago

That's what I was expecting. Can you point us to some code?

rjperes commented 5 years ago

Is that a joke, @richlander? You are asking me for exactly what I'm asking!

rjperes commented 5 years ago

Assuming that MEF does this, which it obviously does, as it instantiates parts, I am asking how to change this!