the previous article C + + performance, C # capacity?! Fish and Bear paw can be both,. NET native to get a lot of friends support and encouragement, but also let me firmly do the promotion of this technology, hoping to let more friends know this technology, so first from the official information translation started.
This series is a small nine school original translation, translated from the Official Microsoft Development Wizard, divided into six themes. This article is the Third topic :. NET native deployment tests and samples .
Wizard Links:C + + performance in C # capacity?!-. Net Native Series: Development Wizard
[ Small Nine school, dedicated to the ordinary language to describe the extraordinary technology.] If you want to reprint, please indicate the source: Small nine of the academy . cnblogs.com/xfuture]
Original:. NET Native Getting Started
. NET native deployment tests and examples
. NET Framework 4.5
Tips |
This topic relies on the pre-release. NET native developer Preview. : Microsoft Connect website. Friendly tips need to be registered. |
The development process step two. NET Native development process detailed
Deployment and Testing:
When you have completed the development process, configured successfully. NET Native tools and updated the runtime directives file, you can begin rebuilding and deploying your app to test your application. The. NET Native native binaries are placed in a subdirectory ilc.out of the build output directory of the project properties configuration. Without this folder, the project has not been successfully compiled by. Net native.
. Net Native currently supports the x64 and arm frameworks, so you can only deploy the application to the appropriate device. You will then need to test and resolve the failure on the device.
If your application does not run properly (especially if the runtime throws a missingmetadataexception or missinginteropdataexception exception), You need to follow the next piece of content: Manually resolve missing metadata exceptions. Starting the first-chance exception (the program has created an exception and is captured and continues to run) can help you discover these bugs.
After testing and debugging errors, you have handled the above exceptions well, you should test some performance optimizations. To perform a performance test, you must change the project build from debug to release to test its release.
Common problems:
The most common problem with. NET native is encountering missingmetadataexception up. This exception can cause unpredictable behavior or even collapse of the program. This section discusses how to debug and resolve this type of exception by adding directives at run time. For information on running instruction formats, refer to:runtime directives (rd.xml) Configuration File Reference. When you add a good Run command, You can deploy and test your application and resolve metadata related exceptions.
Note: Adding instructions should not change the underlying code and should be handled at a higher level. It is recommended that you add instructions at the beginning of a namespace or type, not every piece of code. Machine code Project compile time will also increase after adding instructions.
When dealing with metadata loss exceptions, you should consider the following issues:
1. What did the application do to cause this exception? For example, is it data binding? or serialization and deserialization to get the data? Or is it reflection?
2. Is this exception common? For example, when serializing an object produces the exception, you need to check the test for each serialized part.
3. Use reflection as little as possible. refactor the code to reflect the part as much as possible to replace the mechanism.
Examples of problems encountered in testing:
Example:handling Exceptions when Binding Data
This example is a. Net native project that encounters an missingmetadataexception exception when binding data. The exception information is as follows:
?
1 |
This operation cannot be carried out as metadata for the following type was removed for performance reasons: App.ViewModels.MainPageVM |
The following is information about the associated stack call:
?
1 2 3 4 5 6 7 8 9 10 11 |
Reflection::Execution::ReflectionDomainSetupImplementation.CreateNonInvokabilityException+0x238 Reflection::Core::ReflectionDomain.CreateNonInvokabilityException+0x2e Reflection::Core::Execution::ExecutionEnvironment.+0x316 System::Reflection::Runtime::PropertyInfos::RuntimePropertyInfo.GetValue+0x1cb System::Reflection::PropertyInfo.GetValue+0x22 System::Runtime::InteropServices::WindowsRuntime::CustomPropertyImpl.GetValue+0x42 App!$66_Interop::McgNative.Func_IInspectable_IInspectable+0x158 App!$66_Interop::McgNative::__vtable_Windows_UI_Xaml_Data__ICustomProperty.GetValue__STUB+0x46 Windows_UI_Xaml!DirectUI::PropertyProviderPropertyAccess::GetValue+0x3f Windows_UI_Xaml!DirectUI::PropertyAccessPathStep::GetValue+0x31 Windows_UI_Xaml!DirectUI::PropertyPathListener::ConnectPathStep+0x113
|
This application is a WPF program in which spatial elements (View) in XAML are bound and propertyinfo.getvalue to get the value of the context data carrier (ViewModel) property by type. However, the metadata for this property is missing, so the metadata loss exception is reported.
Solution:
The first step is to set the object to be serializable, ensuring that it is accessible:
<type name= "App.ViewModels.MainPageVM" serialize= "Required public"/>
The second step is to consider whether it is a universal issue. In this case, all viewmodel have this problem, so you should not continue debugging until you modify only one place at a time. Since all ViewModel are in App.viewmodels, the following settings can be made:
<namespace name= "App.viewmodels" serialize= "Required public"/>
Because data binding is reflection-based, it is not possible to change the code to avoid reflection. But there are ways to associate the view with the ViewModel at compile time without relying on the runtime to save the metadata. For example, you can set the Windows.UI.Xaml.Data.BindableAttribute property, which causes the compiler to associate the context at compile time, avoiding the use of runtime Default.rd.xml serialization to fetch metadata.
For Rd.xml, you can refer to the Runtime directives (rd.xml) Configuration File Reference.
You may encounter more problems in development, and you can ask questions in the MSDN forums.
To see the first few of these series you can click: Wizard
< Span style= "Color:rgb (0, 0, 128); >