当改变生成序列化程序集的价值? [英] When to change the Generate Serialization Assembly value?

查看:242
本文介绍了当改变生成序列化程序集的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到WCF的本地网络服务器的客户机WinForm应用程序。 还有在客户端有一个性能问题,我搜索的解决方案,并找到<一href="http://www.mombu.com/programming/windows/t-invoking-web-service-from-winform-app-very-slow-first-call-1575806.html#post6070609">this帖子。

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.

它说的是:

这听起来像在运行时所创建的序列化程序集。尝试   改变序列化大会下拉列表的设置在底部   在属性窗口项目的构建窗格。

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?

我的codeS是在C#中,框架4,打造VS2010Pro。

My codes is in C#, framework 4, build in VS2010Pro.

推荐答案

为了序列化类/结构,序列化程序集需要。这可以在编译时或运行时发生。 Sgen.exe用于产生序列化程序集在编译时; Visual Studio中可以选择自动完成这个过程,因为你已经发现了。

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.

  • 关闭:默认调试配置(感谢 @Alexandru Lache )。不生成序列化程序集在编译时。序列化程序集将在每次应用程序运行时产生的,根据 MSDN

    • Off: Default for Debug configurations (thanks, @Alexandru Lache). Do not generate serialization assemblies at compiletime. Serialization assemblies will be generated each time the application runs, according to MSDN:

      在XML序列生成器不使用时,一个XmlSerializer的生成序列化code和序列化程序集为每种类型的应用程序每次运行时。为了提高XML序列化的启动性能,使用Sgen.exe工具生成那些程序集事先的程序集。这些组件可以被部署到应用程序。

    •   
    • :使用Sgen.exe生成一个序列化程序集在编译时。这样可以节省启动时间,但会增加部署规模。
    •   
    • 自动:默认版本的配置。据官方统计,仅在汇编如果的XmlSerializer 用在你的code,每次的MSDN (感谢, @ L-三)。在我的测试中,这并不总是工作,所以我建议明确,如果你使用的是设置为 的XmlSerializer
    •   

      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.

    • On: Use Sgen.exe to generate a serialization assembly at compiletime. This saves startup time, but increases deployment size.
    • Auto: Default for Release configurations. Officially, only generates assembly if 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.
    • 编辑:我确实有一些麻烦,关闭和自动之间的区别。所不同的是没有明确定义的任何地方。我有在坚持,如果你使用Serializable属性可言,和关闭,如果你不知道。我不会采取部署规模或启动的时间考虑在内。我刚才好像碰到较少的序列化相关的错误,如果我坚持这个规则。

      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.

      在来源评论中提到,我相信启动是指第一次的的XmlSerializer 用在任何给定的类型,而不是最初的应用程序启动。我不能肯定;这是一个有点暧昧。

      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.

      这篇关于当改变生成序列化程序集的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆