Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is. NET Native

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about what is. NET Native. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

What is .NET Native?

.net Native is a set of precompiled tools for compiling generic Windows (UWP) applications in Visual Studio 2015. It can compile managed intermediate language binaries into native binaries, and every managed generic Windows application will benefit from this new technology. The application is automatically compiled into native code before it is installed on the user's device. For more information on how it works, see MSDN.

What will the .NET Native bring?

Depending on the situation, the benefits of .NET Native are varied. In most cases, however,. NET Native will make applications start faster, run better, and consume less user system resources. The specific advantages are as follows:

60% increase in cold start efficiency

40% increase in hot start efficiency

Applications take up less memory resources during native compilation

The system does not need to install Desktop .NET Runtime

Because the application is compiled locally, performance can be improved by taking advantage of native code

Take advantage of industry-leading C# or VB and their programming language tools

Provides a comprehensive and consistent .NET programming model, including extended API, built-in memory management, and exception handling required for writing business models

The difference between Debug and Release compilation modes

The compilation process of .NET Native is very complex, and it takes a little longer to compile than traditional .NET compilation. The advantages mentioned above sacrifice some of the compilation time. Visual Studio reminds developers of this when compiling applications, ensuring a good development experience.

When using the Debug compilation mode, the intermediate language code is running in the application, the .NET system parts are not encapsulated with the application code, and the application depends on the Microsoft.NET.CoreRuntime (CoreCLR) package. This means that developers can enjoy the best development experience. Compilation and configuration are fast, with a wealth of debugging and diagnostic information, and all familiar tools are available in .NET development.

For Release mode, the application uses the .NET Native toolchain by default. Because the package is compiled into a local binary, it no longer contains the .NET framework library. In addition, the package relies on the newly installed .NET Native Runtime rather than the CoreCLR package, and the .NET Native Runtime on the device is always compatible with the application package.

With native compilation of Release, applications can be tested in an environment that simulates user use. During application development, regular testing is important to ensure that errors related to the .NET Native compiler are found and modified. The .NET Native compiler works fine in most cases, but it may not work so well in a few cases, such as an array of more than 4 dimensions that may throw an error. Users end up with a .NET Native compiled application, so it's best to test the version of the application during development, make sure it's correct, and then release it.

It is also important to add that. NET Native eliminates cross-platform compilation mode. Native compilation is architecturally independent, so cross-platform compilation is no longer useful. An additional result is that when developers package an application, all three architectural configurations (x86, x64, ARM) need to be selected to ensure that the application is compatible with all devices.

The .NET Native has changed the way packages are distributed, which is the last major change to the workflow. A major feature of .NET Native is that compilers can be placed in the cloud. When you compile an application package in Visual Studio, two packages are created, one is the .appxpackages file, and the other is the "test" .appx file for side loading. Appxstores contains information about the version of the. NET Native tool chain used by MSIL binaries and applications (also recorded in the AppxManifest.xml file). The compiled package is then placed in the application store and then compiled by the same version of the .NET Native tool chain. Because the compiler is in the cloud, developers can repeatedly modify program defects without recompiling the application locally.

This change brings two other changes to the developer workflow. The first is that developers cannot change the fourth version number of the application package, because the app store needs to change the version number to mark every compilation in the cloud. However, developers can also change the other three version numbers, so there is no need to worry too much. The second is that developers need to pay special attention to the packages uploaded to the app store. The App Store compiles natively instead of developers, so developers cannot upload native binaries generated by the local .NET Native compiler. In this regard, Visual Studio will help developers choose the right file.

To sum up, the main changes brought about by .NET Native are the following:

Periodically test developed applications using the Release pattern

Make sure the fix pack number is 0 (Visual Studio does not allow modification and do not use a text editor to modify it)

Upload only the .appxupload files generated when the package was created to the app store. If the .appx file of the general Windows platform is uploaded, the app store will reject it and report an error

Other tips for using the .NET Native

If developers suspect that the .NET Native has caused some errors, they can try to solve them in the following ways. Because Release mode optimizes the code by default, which loses some of the build files needed in Debug mode, debugging in Release mode may cause errors. Developers can create a new custom pattern to use the .NET Native toolchain without optimizing the code. The details can be found here.

It is undoubtedly a better choice to avoid .NET Native-related errors from the start. Microsoft.NET Native.Analyzer will give a warning if it encounters a conflict between the code and the .NET Native during development.

Thank you for reading! This is the end of this article on "what is. NET Native". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report