I was watching the Microsoft build conference from October last year and I noticed they announced that for building the new Metro style apps, developers can write native code in C#. How is this possible? I'm just curious. Wasn't C# designed (as part of CLI standards) to first be compiled to intermediate byte code and then run on a virtual machine? How can something that runs on a virtual machine be called "native code"?
It has always been possible to call native code from managed code. Generally any .net app that interacts with windows at some point is handing control over to native components.
Historically, to manually invoke native code we would use PInvoke (Platform Invocation) - which allows managed code to call unmanaged functions that are implemented in a DLL.
What's new now is Windows Runtime, basically an ehanced COM-based API. You can read up about it here - http://en.wikipedia.org/wiki/Windows_Runtime - its just making the process easier / less overheard.
EDIT - to be clear, the presentation was not that c# could be compiled to native code. this is still not possible. they were touting winrt as providing a new (cleaner) mechanism for including calls to native code in c#.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With