January 2009 - Posts

We’ve dropped another version of the Managed Extensibility Framework over on our CodePlex site.

Changes since the last drop:

  • Diagnostics improvement. We now provide a lot more information in error messages when something goes wrong with composition. We’ve also made the main types look a lot better under the debugger.
  • Lifetime/Creation Policy. Importers can now request a specific creation policy (ie shared or non-shared) for an injected object if they so want. Non-disposable non-shared objects can now be GC’d before the container is disposed (before it used to hold onto them indefinitely).
  • Ripped AllowNonPublicCompositionAttribute. We now always inject private and internal members.
  • Namespace cleanup. We’ve added a couple of sub namespaces under System.ComponentModel.Composition, called ‘Hosting’ and ‘Primitives’. Hosting contains types commonly used only by host applications, such as ExportProvider, CompositionContainer and the catalogs. Primitives contains types for implementing a custom programming model, such as ComposablePart, ImportDefinition and ExportDefinition.
  • Type name cleanup. Gone are the hideously long type names; AttributedAssemblyPartCatalog, AttributedTypesPartCatalog, AggregratingComposablePartCatalog, and in their place; AssemblyCatalog, TypeCatalog and AggregateCatalog.

Check it out, and tell us what you think.

Posted by David Kean | 4 comment(s)
Filed under: ,

ReflectionTypeLoadException takes the cake with this message:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

This is one of the most frustrating messages to encounter outside of the debugger. What do you think the first thing you are going to do when you hit this in production?….Exactly, look at the LoaderExceptions property, which is impossible without forethought or a debugger.

How could have the loader team improved the usability of this exception ten-fold? By simply outputting the first couple of entries from the property:

Unable to load one or more of the requested types. The first few exceptions are provided below. Retrieve the LoaderException property for more information.
---> Could not load file or assembly ‘Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8e9c13fee402ae29' or one of its dependencies. Strong name validation failed.

Much better. Straight away the user can see the root cause of the problem and can react without needing to attach a debugger.

(As a side note, CompositionException in MEF used to suffer from the same problem when I first arrived on the team; luckily, our latest release fixes this)