XmlSerializer - the first deserialization is very slow

I have a solution with two projects; asp.net MVC application and class library. Let them be called MVC project and CLS project.

In the project CLS, there are two different versions (V1 and V2) of the XSD file that I used to create two serializable classes with the same name, but in different namespaces (V1 and V2) using xsd2code .

In an MVC project, when a user loads an XML file, they CLS.dllare used to deserialize the XML into an object. When the XML file is of type V1, deserialization is very fast, but the XSD file for version V2 is much more complicated, and deserialization can take up to several minutes, only for the first time (this is very fast after that, until the application starts again).

I used the Sgen.exe tool to create a serializer assembly ( CLS.XmlSerializers.dll) for type CLS.V2, to eliminate the first time I created the assembly on the fly and, therefore, improving performance.

I managed to add the Sgen task to Post Build events, and the assembly CLS.XmlSerializers.dllis created every time a project is created. In addition, I used the unit test code in this post to make sure the assembly is loaded, and that is. The test runs silently.

However, the first time the XML file is descripted, it takes a long time. So something else must be wrong. But I do not know what. Please, help.

UPDATE:

Fuslogvw.exe, , , CLS.XmlSerializers.dll . , XML , ?

2:

XSD , (V2) XSD, xs:enumeration, . , . , , - XML , XSD ( xs:string). V2 , V1, Sgen.exe. , Sgen.exe , XML . XML , () .

+6
2

XML, , XmlSerializer . , .

XmlSerializer, , serializer. , , . # System.CodeDOM. XmlSerializer XML XML. Serialize() Deserialize() XML .

: XmlSerializer

: XmlSerializer

+2

x64 jit, . , .

.net 4.6 , x64 jit- (RyuJIT). .net, .

+1

All Articles