Arthur Wang's Blog
Follow me on
  • My General Blog
  • Software Development
    • Latest Articles on Software Development
    • Complete Resources for Developers >
      • Tutorial Information for Developers
      • .NET Developer Blogs
      • Developer Journals and Magazines
      • Developer's Tools
      • Database Development
      • ​Developer Conference and Events
  • Tech
    • Latest Articles on Technology Development
  • Health
  • Money
  • Services
    • Modern Website Design
    • Web Maintenance of Existing Websites Service
    • Corporate Business Consulting Service
  • About
  • Contact
  • Art
  • 中文部落格

Understanding .NET Native Tool Chain Under the Hood

4/27/2016

0 Comments

 
Picture
Why going through all the trouble inventing a new compilation technology such as the .NET Native? 
​
To make the explanation short, if you have a hundred times more powerful processor that is small enough to fit inside the mobile device or any devices, then we are wasting our time on the invention of the new compilation technology.  Since the processor inside the mobile devices like the phone or tablet are much weaker than the desktop computer, and you already know the problem of the slow startup time of Windows application due to the use of dynamic compilation where it means it compiles on-demand.  So let's assume the small device's processor can run the same app, it will take a very long time to do things on the mobile devices, which is unrealistic.  So to minimize the work that the weak processor needs to do, ahead-of-time compiled or static compiled files are packaged along with minimal sets of CLR needed to run on the processor. But if it is compiled ahead of time, how about those dynamic .NET features such as reflection or getting the correct types only at runtime?  There are two things make the static compilation possible.  One is that in the Visual Studio, there is a .rd.xml file that contains runtime directives configuration file that can tell the .NET Native tool chain to make your application reflectable at runtime.  Another thing is the ILC.exe inside the tool chain has the heuristics built-in that predicts what are the things you need to reflect on and what types you want to keep until runtime, and rd.xml files are served as hints for ILC.exe in which that the developers gave.    
Picture
In the process of .NET Native tool chain, the ILC.exe scans the entire stack of the program code and devises a plan to optimize the code at first. If the program has included the 3rd party software, it will try to merge it, and follow by a tree-shaking process where unnecessary codes are removed, and then transforms into pre-compiled codes with necessary information made the code reflectable at the end.  It is further compiled into MDIL (Machine Dependent Intermediate Language) by a C++ optimizer. Finally, the binder, the last chain tool, converted  MDIL into two machine code files: App.dll and App.exe.  The reason to have two files are because of there are two states in a mobile device: initial activation and background task. Each file takes care of different entry point of the application.   

In summary, the .NET Native tool chain made the entire build process possible where it processed the logic and complexity ahead of time before it reached to the device's processor.  In the end, applications start faster and smooth even on the weaker processor. ​
Read Latest Software Development Articles  Read Latest Tech Articles

Picture
Let's Connect!

Arthur Wang

​Arthur is a software developer at his core and has been developing web applications and leading development projects since 2000.  He enjoys learning new technologies and writing about them.


If you would like to read more articles written by Arthur, please subscribe the weekly newsletter from Uniting Digital since he is also a content contributor for the site.
Subscribe

0 Comments



Leave a Reply.

    Arthur Wang

    @ArthurWangLA
    MCSD App Builder
    MCSD Web Applications
    ​Member of Windows Insider Program & HoloLens Developer Community & Dev Center Insider Program

    Over 17+ years of  experience in web-based software development & management.  Specialized in Microsoft technology with c# language and its architecture design.  MCSD, MCSE, Microsoft Specialist, MCP + Internet, and B.S. from UCLA

    Archives

    August 2018
    March 2018
    January 2017
    December 2016
    May 2016
    April 2016
    March 2016
    February 2016
    April 2014

    Categories

    All
    API
    Arduino
    ASP.NET
    Cognitive
    CSS
    Database
    Deep Learning
    DevOps
    Electronics
    Flexbox
    HTML5
    IoT
    Katana
    Machine Learning
    Management
    .NET
    .NET Core
    Neural Network
    OWIN
    Programming
    Programming Tools
    Recognition
    Security
    SQL Server
    UWP
    Visual Studio
    Web API
    Web Developer

    RSS Feed

    Latest Articles

© 2014-2020 ArthurWiz.com All Rights reserved. | Home | About |
Protected by Copyscape