I have a client winform application that connects to the local network server of WCF. There has a performance issue on the client side and I searched for the solution and found this post.
It says there that:
This sounds like the serialization assemblies being created at runtime. Try changing the settings of the Serialization Assembly dropdown at the bottom of the Build pane of the properties window for the project.
My question is When to change the Generate Serialization Assembly value and what value should I change it into to improve the performance of my client side application?
My codes is in C#, framework 4, build in VS2010Pro.
The serialization assembly improves the startup performance of a XmlSerializer when it serializes or deserializes objects of the specified types.
In order to serialize classes/structs, serialization assemblies need to be generated. This can happen at compiletime or runtime. Sgen.exe is used to generate serialization assemblies at compiletime; Visual Studio can optionally automate this process, as you have discovered.
When the XML Serializer Generator is not used, a XmlSerializer generates serialization code and a serialization assembly for each type every time an application is run. To improve the performance of XML serialization startup, use the Sgen.exe tool to generate those assemblies the assemblies in advance. These assemblies can then be deployed with the application.
XmlSerializer
is used in your code, per MSDN (thanks, @L-Three). In my tests, this didn't always work, so I recommend explicitly setting it to On
if you are using XmlSerializer
.So, my answer would be this: if you are concerned about startup time, and you use the Serializable
attribute even once, set the option to On. If you are more concerned about deployment size, change it to Off. I never leave it on Auto anymore, because I don't trust it. Like I said, it seems to be the same as Off, but I wouldn't count on it.
Edit: I'm definitely having some trouble differentiating between Off and Auto. The difference isn't clearly defined anywhere. I'd stick with On if you use the Serializable attribute at all, and Off if you don't. I wouldn't take deployment size or startup time into account. I just seem to run into fewer serialization-related bugs if I stick to that rule.
After a review of the sources mentioned, I believe "startup" refers to the first time an XmlSerializer
is used on any given type, not initial application launch. I can't be sure; it's a bit ambiguous.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With