How to accelerate XML deserialization (simplified framework set 2.0sp1, wince4.2)-seek technical support from Microsoft

Source: Internet
Author: User

In fact, this problem was submitted to Microsoft technical support on June 13,. However, until today, there is no perfect result for this problem (their best advice is to parse the XML file by yourself ), I had to ask Microsoft's technical support to close the problem.

The key to the problem is: 1. Currently, the simplified framework does not support binary serialization.

2. XML serialization does not support customization.

3. deserialization code encapsulation is too powerful, cannot be configured, and no progress feedback is provided.

4. The deserialization process consumes too much CPU time and cannot display progress animations in other threads.

I wrote down the communication process below to give a reference to my friends who have encountered similar problems.

Bytes ----------------------------------------------------------------------------------------------------

The following is a summary of the problem:
========================================================== ======================================
Q: Is there a way to accelerate the xmlserializer deserialization process?
A: The deserialization process of xmlserializer depends on the complexity of the deserialization class and the processing capability of the hardware platform. On the embedded platform
In general, the hardware processing capability is limited, so the deserialization process will be much slower than the application on the desktop. So for now, this behavior is
Expected. In addition, there are no methods such as binary serialization or custom serialization in. NET Compact framework. If
To accelerate this process, you can use the xmltextreader class to manually analyze the XML file and then reflect the object.
========================================================== ======================================

 
Question title:   Platform: Host Machine Windows XP SP2 vs2005 lower machine: wince 4.2 streamlined framework set 2.0 SP1 1. xml deserialization problems (XML files are serialized...
Product:   Microsoft Visual maxcompute 2005 professional
Sent:   2007/3/13 16:20:38
Last Update Time:   2007/8/7 16:45:08
 
Description:   Problem description: Platform: PC Windows XP SP2 vs2005
Lower COMPUTER: wince 4.2 simplified framework set 2.0 SP1
1. xml deserialization (XML files are automatically generated for serialization)
When the default value (for example, 18xx years) of the wince system fails deserialization, an error message is displayed, indicating that the XML file is incorrect.
An XML file of about 11 mb indicates a deserialization failure on the lower computer. This action contains the information of an image and continues to add some XML data elsewhere in the document to run properly. The same program works normally on the host computer.
In addition, whether or not the deserialization progress control can be provided, because the deserialization of the lower computer is particularly slow, and the CPU resource consumption is high, so the progress cannot be displayed.
2. Font line feed control: the text is normally displayed on the upper computer, but not on the lower computer.
Related code:
Stringformat sformat = new stringformat ();
Sformat. Alignment = alignment;
Sformat. linealignment = stringalignment. Center;
E. drawstring (text, Font, new solidbrush (forecolor), rect, sformat );
Operating System: Windows XP
 
Discussion
Original problem: Microsoft Visual Studio 2005 professional   Send reply
Microsoft reply-16:45:12
Microsoft reply-19:03:14
From: Jimmy Zhu
Sent: Friday, July 27,200 pm
To: 'Ye fan'
Cc: Rafe Wu
Subject: Re: srz070313000366

Hello, Mr. Ye:

I called your company several times today, but your company's switchboard seems to have been busy, so there is no way to contact you.

For the performance problems caused by xmlserializer, after a period of research, we have obtained some useful information.

First, it is also the most important problem. We need to determine the root cause of this performance problem is that the XML file is large, the long wait time caused by too many Io actions is still because xmlserializer spends too much time parsing XML documents. In the embedded platform, whether the processor capabilities or memory size are limited, you can find that it takes a long time to open the windows directory using a file browser. Browsing the folder on the desktop PC can be completed almost instantly. So if it is because of hardware or driver problems, the best solution is to put the deserialization work in a separate thread, then, change the application icon to busy in the main thread.

If xmlserializer spends too much time parsing XML documents, we recommend that you use the following methods for optimization:
1. Keep the element and attribute names as short as possible
2. Try to use system. xml. xmlnodereader. Skip

In addition, the speed of your deserialization is also related to the internal structure of the object during serialization. If your object contains a large array, there is still a way to speed up the deserialization process.
You can use xmltextreader to manually reverse sequence this object. If the structure of the object is complex, this method is not easy to implement.

In the next step, can you provide the XML file generated by serialization and the necessary Type Definitions for us to perform some tests to find out the root cause of this problem?
At the same time, I also added my colleague Rafe Wu who was studying with me to this email. We will conduct further research on this issue. Thank you for your cooperation!

Best regards,
Jimmy Zhu

Developer support group
Global technical support center, Greater China region (GCR gtsc)
<Mailto: jimmyzh@microsoft.com>

Delighting our MERs Mers is our #1 priority. we welcome your comments and suggestions about how we can improve the support we provide to you. please feel free to email our managers at <mailto: gtecfb@microsoft.com>. you can also contact my manager Li-Ming Fan at (86-21) 6469-1188 Ext. 6330 or by sending email mailto: lmfan@microsoft.com <mailto: wenyu@microsoft.com>.

Microsoft reply-11:55:08
From: ye fan [mailto: yefan@vip.sina.com]
Sent: Thursday, July 05,200 7 AM
To: Jimmy Zhu
Subject: Re: srz070313000366

Jimmy Zhu, hello!

Okay. Thank you!

Microsoft reply-11:54:32
From: Jimmy Zhu
Sent: Thursday, July 05,200 7 AM
To: 'Ye fan'
Subject: Re: srz070313000366

Hello, Mr. Ye:

Sorry for the inconvenience.

I'm glad to continue working with you to solve this problem. According to the phone number, I learned that you are currently in the situation that you need to transmit some configuration information between the host computer and the lower computer. The specific operation is that the upper computer serializes the configuration information of more than 20 classes, and the lower computer deserializes these classes. In the actual operation process, the upper computer can perform serialization in time, but the lower computer is unable to complete deserialization in time due to its limited hardware processing capability. So we will use the following several aspects to see if there is a way to improve the overall deserialization efficiency.
1. Can I customize serialized and deserialized content in. Net CF 2.0? If customization is possible, we can serialize and deserialize some attributes.
2. Is there any pre-processing method in the deserialization process to improve the serialization efficiency?
3. Can I use some methods to prompt users during the deserialization process?

Since these contents may involve the specific implementation details of. Net CF, the entire study process may take some time. In this process, I will give you some progress reports on a regular basis. If you have any questions or information, you can contact me at any time. We hope to work together to solve this problem. Thank you.

Best regards,
Jimmy Zhu

Developer support group
Global technical support center, Greater China region (GCR gtsc)
<Mailto: jimmyzh@microsoft.com>

Delighting our MERs Mers is our #1 priority. we welcome your comments and suggestions about how we can improve the support we provide to you. please feel free to email our managers at <mailto: gtecfb@microsoft.com>. you can also contact my manager Li-Ming Fan at (86-21) 6469-1188 Ext. 6330 or by sending email mailto: lmfan@microsoft.com <mailto: wenyu@microsoft.com>.

Your reply-17:05:28
Problem description: "You want to use code to control the fields to be serialized in a custom class". This problem is preferred.

Specifically, it should be in the simplified framework set (. NET 2.0), how to use code to control the XML serialization and deserialization of common fields of the class.

Non-Keyword Method (for example, key sub-xmlignore) should be controlled using functions and the like.

In addition, I think that "text display is inconsistent with Windows platform on the wince platform" is also a bug, because it is run under the same simplified framework and the same font, and I hope this can also be solved.

-------------------------------------------
Do you have to post the question here for your response? The email has been sent long ago !!!!!!!!!! Another problem I encountered was that Mr. Liu responded very well.

Microsoft reply-16:16:17
From: Jimmy Zhu
Sent: Friday, March 23,200
To: 'Ye fan'
Subject: Re: srz070313000366

Hello, ye fan:

Sorry, I have a task this week, so I just saw your email.

Based on what you said in the email, I can summarize the following questions:
1. We hope to provide an event to feedback the deserialization progress.
2. You want to use code to control the fields to be serialized in a custom class.
3. We hope to provide methods or techniques for accelerating deserialization.
4. Reflecting a problem, some XML files will fail to be deserialized on the wince device.
5. The text display is inconsistent with that on Windows.

Each of these problems is an independent issue, and each of them must be investigated and researched to draw a conclusion, therefore, we need to develop a case for each problem to track the status and results of the problem for archiving and recording. It should be pointed out that the third issue falls within the scope of performance adjustment. Therefore, the case should be filed as an advisory case. Of course, if the product group for a problem is identified as a bug, Microsoft will not charge you for this case, so please rest assured. For the series of questions you raised, I don't know which one do you want to solve first in this case?

Thank you.

Best regards,
Jimmy Zhu
Developer support group
Global technical support center, Greater China region (GCR gtsc)
<Mailto: jimmyzh@microsoft.com>

Delighting our MERs Mers is our #1 priority. we welcome your comments and suggestions about how we can improve the support we provide to you. please feel free to email our managers at <mailto: gtecfb@microsoft.com>. you can also contact my manager Wen Yu at (86-21) 6469-1188 Ext. 6303 or by sending email <mailto: wenyu@microsoft.com>.

Your reply-8:52:30
Problem description: vs2005 Development Problem Description
1. xml deserialization
(1) Slow deserialization
The deserialization code is as follows:
Public static embedproject xmldeserialize (string xmlfile, type [] type)
{
Try
{
// Known type
Const int policypenum = 28;
Type [] mtype = new type [policypenum + type. Length];
Mtype [0] = typeof (embedform );
Mtype [1] = typeof (metaline );
Mtype [2] = typeof (metacircle );
Mtype [3] = typeof (metaellipse );
Mtype [4] = typeof (metachord );
Mtype [5] = typeof (metarectangle );
Mtype [6] = typeof (metaroundrectangle );
Mtype [7] = typeof (metapoy );
Mtype [8] = typeof (metabitmap );
Mtype [9] = typeof (metabutton );
Mtype [10] = typeof (metalabel );
Mtype [11] = typeof (jsonext );
Mtype [12] = typeof (metasymbol );
// Extended elements
Mtype [13] = typeof (meta3dpipe );
Mtype [14] = typeof (metarealtimecurve );
Mtype [15] = typeof (metahistorycurve );
Mtype [16] = typeof (metadataform );
Mtype [17] = typeof (metareportforms );
Mtype [18] = typeof (metapilotlamp );
Mtype [19] = typeof (metaswitch );
Mtype [20] = typeof (metainstrument );
Mtype [21] = typeof (metavalve );
Mtype [22] = typeof (metakettle );
Mtype [23] = typeof (metapump );
Mtype [24] = typeof (metamotor );
Mtype [25] = typeof (metaconveyerbelt );
Mtype [26] = typeof (metaflow );
Mtype [27] = typeof (metasign );

//-------------

For (INT I = mtype. length; I <mtype. Length + type. length; I ++)
{
Mtype [I] = type [I-mtype. Length];
}

Embedproject xmldata = new embedproject ();
Stream Sf = new filestream (xmlfile, filemode. Open, fileaccess. Read, fileshare. None );
Xmlserializer xmls = new xmlserializer (typeof (embedproject), mtype );
Xmldata = (embedproject) xmls. deserialize (SF );
SF. Close ();
Return xmldata;
}
Catch (exception E)
{
MessageBox. Show ("deserialization failed:" + xmlfile + "<" + E. Message + ">", "easyhmi ");
Return NULL;
}
}
Using the public list <embedform> mform = new list <embedform> (); statement, serialize multiple classes to the same XML file (the project must be saved to one file, but many XML files are not allowed), and then use the above Code for deserialization.
Problem: about 1 ~ Deserialization can be completed in 3 seconds (depending on the file size). However, it takes 20 ~ The deserialization can be completed in 30 seconds, and the CPU is exclusive during the deserialization. Other threads are basically in the blocking status.
The expected solution is as follows:
1. Whether an event can be provided to feedback the deserialization progress;
2. Can I customize XML serialization? I want to use code to control the fields to be serialized in each class;
3. Provide methods or techniques for accelerating deserialization;
In addition, the bug feedback shows that the same XML file (about 11 Mb, not only because of the size, can be successfully added when some classes are added to the serialized content) is successfully deserialized on the host computer, deserialization fails at the lower computer (column Y in row X is prompted ).
2. In the. NET simplified framework set 2.0 on the wince platform, the text display is inconsistent with that on the Windows platform, for example:

Link: http://p.blog.csdn.net/images/p_blog_csdn_net/yefanqiu/23649/o_%e6%96%87%e5%ad%97%e6%95%85%e9%9a%9c.jpg
The implementation code is as follows:
Stringformat sformat = new stringformat ();
Sformat. Alignment = alignment;
Sformat. linealignment = stringalignment. Center;
E. drawstring (text, Font, new solidbrush (forecolor), rect, sformat );

Microsoft reply-14:36:15
From: Jimmy Zhu
Sent: Wednesday, March 14,200 pm
To: 'efan @ vip.sina.com'
Subject: srz070313000366

Hi mr. Liu,

Thank you for contacting Microsoft gtsc. My name is Jimmy. I will be working with you on the service request srz070313000logs.

According to the problem description in case log, there are two questions for. Net CF development on Windows CE platform.
(1) question about XML deserialize issue.
(2) font display issue on WinCE device.
Please correct me if I misunderstood. as we are limited to handle one issue in one case, cocould you please separate one question to another case and let me know which one shall we focus in this case? I will go ahead and do some research based on your response. Please don't hesitate to let me know if there is any concerns or comments.

Thank you.

Best regards,
Jimmy Zhu
Developer support group
Global technical support center, Greater China region (GCR gtsc)
<Mailto: jimmyzh@microsoft.com>

Delighting our MERs Mers is our #1 priority. we welcome your comments and suggestions about how we can improve the support we provide to you. please feel free to email our managers at <mailto: gtecfb@microsoft.com>. you can also contact my manager Wen Yu at (86-21) 6469-1188 Ext. 6303 or by sending email <mailto: wenyu@microsoft.com>.

Your support request-16:20:38
Problem description: Platform: PC Windows XP SP2 vs2005
Lower COMPUTER: wince 4.2 simplified framework set 2.0 SP1
1. xml deserialization (XML files are automatically generated for serialization)
When the default value (for example, 18xx years) of the wince system fails deserialization, an error message is displayed, indicating that the XML file is incorrect.
An XML file of about 11 mb indicates a deserialization failure on the lower computer. This action contains the information of an image and continues to add some XML data elsewhere in the document to run properly. The same program works normally on the host computer.
In addition, whether or not the deserialization progress control can be provided, because the deserialization of the lower computer is particularly slow, and the CPU resource consumption is high, so the progress cannot be displayed.
2. Font line feed control: the text is normally displayed on the upper computer, but not on the lower computer.
Related code:
Stringformat sformat = new stringformat ();
Sformat. Alignment = alignment;
Sformat. linealignment = stringalignment. Center;
E. drawstring (text, Font, new solidbrush (forecolor), rect, sformat );
Operating System: Windows XP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.