开发者

MS CRM 4.0 SDK - Initial query delay / speedup loading of .NET applications

开发者 https://www.devze.com 2023-01-26 10:04 出处:网络
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 a

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 crmserv开发者_如何学运维ice 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.


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

  • http://blogs.msdn.com/b/crm/archive/2009/02/02/boost-performance-with-pre-generated-xmlserializers.aspx
  • http://msdn.microsoft.com/en-us/library/ee704594.aspx
0

精彩评论

暂无评论...
验证码 换一张
取 消