I heard that the new WinRT is an unmanaged framework and it is based on COM, but somehow they figured out something to make mapping between WinRT and managed code easier. I would like to know how this mechanism works?
Asked
Active
Viewed 945 times
6
-
You might want to check out the answer to this question here: http://stackoverflow.com/questions/7416826/how-does-the-new-windows-8-runtime-compare-to-silverlight-and-wpf – dodgy_coder Sep 20 '11 at 05:10
1 Answers
9
The Windows Runtime represents all APIs in metadata, which the various language projections (C++, JavaScript and C#) read.
Because the API shape is described in metadata, the language runtimes and compilers can reason about the APIs and know how to generate code for those APIs.
For the CLR, the job is a tiny bit easier, since the metadata format is ECMA 335, which is the CLI metadata format used by the CLR - thus the translation is slightly easier for the CLR.
But in general, the translation is straightforward given that you have a machine readable representation of all the APIs present on the machine.

Larry Osterman
- 16,086
- 32
- 60
-
thanks for the answer. Is there any resource or articles that describes where is this metdata can be found? how this metadata is create and can be read? – gyurisc Sep 20 '11 at 07:18
-
I found an to my question here - http://stackoverflow.com/questions/7416826/how-does-the-new-windows-8-runtime-compare-to-silverlight-and-wpf – gyurisc Sep 20 '11 at 07:27
-
2One other big change is that all WinRT components have metadata available for them, just like .NET assemblies. In COM you kinda sorta had that with typelibs, but not every COM component had them. For WinRT, the metadata is contained in .winmd files - look inside "C:\Program Files (x86)\Windows Kits\8.0\Windows Metadata\" in Developer Preview. If you poke around, you'll see that they are actually CLI assemblies with no code, just metadata tables. You can open them with ILDASM, in fact. Note, this doesn't mean that WinRT itself is managed - it simply reuses the file format – gyurisc Sep 20 '11 at 07:28
-
1@gyurisc Also have a look at "C:\Program Files (x86)\Windows Kits\8.0\Include\winrt\RoMetadataApi.idl". – Pavel Minaev Sep 20 '11 at 09:56
-
3There are two sets of metadata in the system - the metadata in system32\winmetadata and the metadata in the SDK. The system metadata is used for JavaScript and the CLR at runtime, the SDK metadata is used for C++ and C# apps (and the IDE) at compile time. – Larry Osterman Sep 20 '11 at 13:31
-
So "metadata" in the same sense as typelibs and headers then, as suggested? Just a "modern stone age family" format compilers need to understand? Without peeking, XML I assume. – Bob77 Sep 20 '11 at 17:28
-
There are no headers, just metadata. And our metadata files can express far more than typelibs can. – Larry Osterman Sep 21 '11 at 00:57