MS CRM 4.0 SDK - .NET 应用程序的初始查询延迟/加速加载
我正在使用适用于 MS CRM 4.0 的 C# .NET SDK。更特别的是,我使用了SDK的XRM接口。
当我启动客户端应用程序时,第一个查询(例如获取所有 crm 系统用户)的开销约为 5 秒。开销发生在通过网络发送任何内容之前(在wireshark中观察到)。这就是为什么我猜测延迟与一些 .NET 加载开销有关。
使用 CrmService 时的初始延迟是由两件事引起的。第一的 必须编译 CrmService 代理类(从 IL 到本机)并且 必须加载序列化。这需要大量的处理 因此时间。此编译仅在第一次实例时发生 crmservice 代理是在 AppDomain 中创建的。
第二次,当第一次在服务器上执行调用时附加 类等可能需要加载。
这是 .NET 框架的正常行为。您可以优化加载时间 通过使用 WSDL 工具生成新的服务代理来为 CrmService 提供服务 清除您不使用的所有请求和对象。做的问题 这就是工作量很大。
假设上述解释适用,除了手动编辑生成的代理类之外,还有其他方法可以避免延迟吗?
我尝试使用 GAC 和本机映像 - 但没有成功。
I am using the C# .NET SDK for MS CRM 4.0. More especially, I use the XRM interface of the SDK.
When I start my client application, the first query (e.g. get all crm systemusers) has an overhead of about 5 seconds. The overhead occurs before anything is sent via the network (observed in wireshark). That's why I guess that the delay is related to some .NET loading overhead.
I found some explanations at http://www.eggheadcafe.com/software/aspnet/31916049/the-initial-delay-when-using-the-crmservice-is-caused-by-two-things.aspx:
The initial delay when using the CrmService is caused by two things. First
the CrmService proxy class has to be compiled (from IL to native) and the
serialization has to be loaded. This requires a large amount of processing
and therefor time. This compilation only occurs the first time an instance of
the crmservice proxy is created in an AppDomain.Second when a call is executed on the server for the first time additional
class and such may need to be loaded.This normal behaviour for the .NET framework. You can optimize the load time
for the CrmService by generating a new service proxy using the WSDL tool and
clearing out any requests and object you don't use. The problem with doing
this is that it is a lot of work.
Assuming that the explanation above applies, is there anyhing else which can be done to avoid the delay - except manually editing the generated proxy classes?
I experimented with GAC and native images - without success.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以放弃使用强类型 WSDL 接口代理类,而简单地使用 SDK 的动态实体类。
这不需要生成或加载序列化类。但这需要您使用动态实体表示,这更麻烦且容易出错。
You can forgo the use of the strongly typed WSDL interface proxy classes and simple use the dynamic entity class for the SDK.
This does not require generation or loading of the serialization classes. But it would require you to use the dynamic entity representation which is more cumbersome and error prone.
请参阅这些链接,了解减少启动延迟的可能方法
See these links for a possible approach for reducing the startup delay