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. ​
0 Comments

Understanding the New .NET Core Technologies

4/27/2016

0 Comments

 
.NET Code Life Cycle in Desktop and UWP Applications
.NET Code Life Cycle in Desktop and UWP Applications
To understand the new .NET technologies, we must first understand the old one in terms of the life cycle of the code from design, build, deploy, to runtime.  As we have mentioned previously, one purpose of the old .NET technologies was trying to solve a problem in which that the operating system can accommodate source codes written in different programming languages and deployed the application codes in the form of DLL files.  These applications are either Windows Desktop applications or ASP.NET web applications that can be executed by the processor when the user interacts with them on the Windows-based computer or server.  At runtime,  the CLR executes these DLL files in a Just-In-Time (JIT) fashion.  As a result, the startup time for any Windows app is always slow since it needs to do the compilation of the entire application at the first time it loads.  
​

In the .NET Core technologies, one major purpose is to be able to make the source code runnable in multiple platforms regardless of the type of devices: laptop, phone, tablet, and HoloLens.  The goal of CoreCLR is to support other operating systems as well. For example, an application written in C# code can be deployed and run on Android phone or iPhone or even on Linux. In contrast, CoreCLR is not used for building for the desktop application, or at least for now.  It creates Windows Store application or called the Universal Windows Application and ASP.NET apps and services.    

Only a subset of CoreCLR is merged with your app code to produce the final native code.  In this way, it minimizes the executable file size and processor's load, and it was already compiled ahead of the time and serves static codes to the processor instead of dynamically. Consequently, the startup time is much faster than the old CLR method.  We will describe how it works in detail next.  

Prior to Visual Studio 2015, there is no big difference between the Debug mode and Release mode when you are running your application in term of the process of building the application.  The build process is similar except there are more debugging features participating in the process.  In the Visual Studio 2015, there is a significant difference between these modes on how the build process is done.  In the release mode, it goes through .NET Native process where the .NET Native tool chain compiles the IL (Intermediate Language) binaries into native binaries.  Unlike the old way, this time, you need to specify the CPU architecture that this app deploys to.  In the Debug mode, you are running in a similar fashion to the previous Visual Studio, but instead of using the CLR, you are using the CoreCLR, a brand new .NET Core Runtime, to compile and run your codes.  This new CoreCLR supposes to give you fast compilation and deployment and rich debugging and diagnostics features.    

Unlike the old way where you package your final codes into executable files, such as DLL or EXE, which look identical to the files running in the release mode, you will need to fill some additional information about your application on a submission form and a package will be created by the Visual Studio for submitting to the Windows Store.  The final package you are submitting to the store is not in the form of native binaries, but they are IL binaries instead.  It is because the Windows Store will take care of the final build for your application.  It creates different app packages by using the .NET Native tool chain depending on what CPU architectures you specified on the submission form that your apps can run on.
Read Part 3 of 3: ​Understanding .NET Native Tool Chain Under the Hood
0 Comments

The New Era for Microsoft Software Development

4/27/2016

1 Comment

 
Picture
The .NET technologies were developed by Microsoft at the end of the year 2000. One of the purposes was to streamline the process from writing the source codes with different programming languages to one common language codes that can be executable on any Windows operating system guarantee as long as the required version .NET is installed.  This Common Intermediate Language (CIL) code stored in the form of DLL could be dynamically compiled into machine code by .NET Common Language Runtime (CLR) when the user interacts with the application.  This compiled technology is also known as just-in-time compilation (JIT) which has dominated the software development landscape for many years.  
​

Around the year 2008, the sales of PC began to decline at a rapid pace, and it shocks the .NET development community as well since developers were having a hard time to compensate the rapid changes of the environment and the needs of building mobile applications as the number of different types of mobile devices begin to soar.    
The need for letting the .NET developers to develop software cross-platform within the Windows environments and be able to create applications runnable not just in Windows operating system, but also in Android, Linux, and Apple system, becomes a priority for Microsoft as they try to revamp the .NET technologies from the ground up.  In November of 2014, Microsoft announced modular-designed .NET Core and its CoreCLR implementation as a way to address the cross-platform issues. But not until recently, the release of Windows 10 marks the new era of new operating system and software development since Windows 10 adopt the new .NET technologies.
Read Part 2 of 3: ​Understanding the New .NET Core Technologies
1 Comment

Understanding the Old and New .NET Technologies Through the Journey of C# Source Code to Executable Machine Code

4/27/2016

1 Comment

 
​The goals of this article go from viewing the .NET technologies from a big picture to details on how new .NET Core Native works under the hood.  I've broken it into three smaller parts:
  • The New Era for Microsoft Software Development 
  • Understanding the New .NET Core Technologies
  • ​Understanding .NET Native Tool Chain Under the Hood
1 Comment

Officially As a Part of the Microsoft HoloLens Community

4/20/2016

0 Comments

 
I just received the email from the Microsoft HoloLens Team that my application for the Microsoft HoloLens Development Edition has been approved!  After the Build 2016 Event on March 30 - April 1, Microsoft announced the availability of the HoloLens Development version for qualified application developers.
Picture
To develop software for HoloLens, your develop PC must have Windows 10 Professional version with GPU capable of  DirectX 11.0 or later.  Only professional version support Hyper-V.  For the software portion, you need to install the VS 2015 Update 2 and community version is sufficient.  Unity HoloLens Tech Preview Beta 10  http://unity3d.com/unity/beta  Unity 5.4.0B13 (4/4/2016)

If you encounter an error when you tried to install Unity, such as "'WSA' does not exist in UnityEngine.VR", this means that you need to install the Unity Editor first!  http://unity3d.com/pages/windows/hololens

Run as Adminstrator on this UnitySetup64(1) - 311 MB
C:\Program Files\Unity Hololens 5.4.0b10-HTP\
Then you can install the UWP runtime: Install UnitySetup-Metro-Support-for-Editor-5.4.0b10-HTP 

Finally, there is HoloLens Emulator.  Although the requirement for installation is Windows 7 SP 1, it is useless since VS 2015 is unable to run the HoloLens emulator if your OS is not Windows 10.  

Picture
The emulator allows you to run apps on Windows Holographic in a virtual machine without a HoloLens. This package also includes holographic DirectX project templates for Visual Studio. Here is a screenshot of the emulator installation.  It may take a while!
Picture
Building HoloLens apps will be an exciting experience since we can make something in the virtual world and bring them to live by mixing them in the reality and be part of your real world.  It's an amazing journey!
0 Comments

    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