I want to output the types in a .winmd file given its path. I copied a winmd file from my Windows 8 Developer Preview machine to my dev machine. I wrote a small test app (in
WinMDs are metadata only assemblies. Using ReflectionOnlyLoadFrom should do the trick.
The following code works.
var assembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom(winmdPath);
foreach (var type in assembly.GetTypes())
{
Console.WriteLine("type found name = " + type.Name);
}
While .winmd files use the ECMA 355 file format, they are NOT .Net assemblies, and it is highly unlikely that you'll be able to read the files using the .Net framework directly.
If you use the version of ILDASM shipped with the developer preview, you can view the types in the files visually. You can also use ildasm to dump a text file containing the types in the metadata file. I believe that .Net reflector can also do this.
If you DO need to enumerate types in a winmd file programmaticly, I suggest that you use the unmanaged metadata reading APIs. That's how we read metadata files for our development tools internally.
If you're running on the developer preview build, I'll suggest you look at the RoGetMetaDataFile API - this is the API used by the Chakra javascript engine to open the metadata file for a particular type.
To work with *.winmd files you must set in your project file inside PropertyGroup
<TargetPlatformVersion>8.0</TargetPlatformVersion>