This project has moved. For the latest updates, please go here.

ExportTypeIdentity and TypeName

Jan 27, 2010 at 1:52 PM

MEF metadata ExportTypeIdentity has only FullName from Type.

How can we get access to AssemblyQualifiedName?

Jan 27, 2010 at 4:43 PM

There isn't a direct way to get the AssemblyQualfiedName for an Export/Import in general.

May I ask what it is your trying to accomplish?


Jan 28, 2010 at 6:40 AM

I'm trying to get access to type name which is Exported without adding custom attribute defining that type.

But, while doing that I noticed that even ExportTypeIdentity metadata doesn't have full type name.


It would be great if


public class ExportedClass

{... }


would mean MEF includes Metadata which has ExportedClass AssemblyQualifiedName in it.

Right now I need to define by hand



public class ExportedClass

{... }


 if I want to get access to Type of class being exported via Lazy<>

because I can't create instance of that Type at that time.

Jan 28, 2010 at 3:41 PM

ExportTypeIdentity is not actually the full type name, while it does sometimes look like that it is really a custom "hash" of the type name that we generate. 

We explicitly don't want to include the AssemblyQualifiedName of the implementation type because that will allow (and possibly encourage) bad practices. In particular it allows the importer to take strong dependencies on concrete types which defeats MEF's loose coupling goal. Every import should be treated equal and only be used via the exported interface and the metadata.

Out of curiosity can you explain why you need the concrete type on on the import side?

Jan 29, 2010 at 6:21 AM

I'm using Autofac as a container and MEF as a plugin provider.

Some plugins have other dependencies, so they need to be registered in the container.

I need to know their type so I can register them into the container.


Is this something you consider bad practice? Do you have any suggestion on how to implement this besides adding custom metadata like I'm doing now?