10-4 Episode 25: Fixing PIA Pains with Type Equivalence

In this episode of 10-4, we take a look at a new library in .NET Framework 4 and how it helps developers write applications that are more extensible and easier to maintain than before.
For more information on the Managed Extensibility Framework, make sure to check out its home on Codeplex:
http://www.codeplex.com/mef.
Source code for demo:
http://cid-1b51ad25aad8fc86.skydrive.live.com/self.aspx/.Public/ManagedExtensibilityFramework.zip
For more 10-4 episodes, be sure to visit:
https://channel9.msdn.com/shows/10-4
10-4! Over and out!
Nice intro! I had a question, and I tried looking around the CodePlex documentation first, and did not find the answer.
This is more of a problem with my documentation reading skills than the authors document writing ability.
Anyways, back to the question, if I have two or more equivalent exports, that have their imports satisfied, how is the import resolved? First in wins? I think it has something to do with the catalog.
Very nice, especially the part about the NetworkCatalog.
So you mention that the source is (will be?) available online. But I cannot find a link or attachment?
Remco.
It was in the post comments... http://www.codeplex.com/mef
That's the MEF site. I mean the source from this presentation/example application. (or is this included in MEF Samples?)
Sorry for the delay! The code can be found at http://cid-1b51ad25aad8fc86.skydrive.live.com/self.aspx/.Public/ManagedExtensibilityFramework.zip
Please let me know if that doesn't work!
In that situation, we will throw an error because we were expecting to only find one, and we found two. This is the only real "deterministic" way to behave for us.
[Obsolete]
System.AddIn
Very good explanation of MEF. I was looking into Spring.Net. How is MEF compared to Spring. Is it configurable using XML files or is it done through code.
Why not Spring.Net?
Just want to hear your take on it; I'm new to Dependency Injection.
Thanks.
Omg, this is very cool.. great episode..
I was wondering if there are any performance implication when linking dependencies to all objects?
Also, if you can talk more on further episodes about what other features like this will come in .net framework 4 that help us follow other best practices, patterns or SOLID principles easily.
Again, great job!
Thanks,
Excellent. Simple and cool stuff to use in the real world.
Spring is an IoC container while MEF is for plugins. An IoC is used when you know your dependencies at design time and typically deals with "one" dependency (for that area of the app) while MEF deals with many.
For example, with IoC, at design/debug time you may inject a simple console logger for your app or even a mock logger while at production/runtime you will replace it with a proper logger that writes to a file or database but with MEF at runtime you are looking to discover "all loggers" that are available and call them (of course you can just pick up a single logger using the catalog) so your output can be piped to many.
You could use MEF to wire dependencies like an IoC but it is not meant for or optimized for such behavior. MEF also has advantages with the way stuff is exported and imported in that it is not tied to types which means that your app can be opened up to plugins written in dynamically typed languages.
HTH,
Benjy
Favorite part:
"Hey are you a plumber? can you satisfy my needs?"
I LOL'd
Great video, too bad the quality of the video made it imposible for me to read the code.