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.