PRB: Delay on First Method Invocation on Web Services (323577)



The information in this article applies to:

  • Microsoft Web Services (included with the .NET Framework 1.1)
  • Microsoft Web Services (included with the .NET Framework) 1.0

This article was previously published under Q323577

SYMPTOMS

Although you have used the Native Image Generator (Ngen.exe) to pre-compile an assembly to native code, you may still see a delay that lasts a few seconds on the first method invocation on the Web service.

CAUSE

There are two initialization steps for a Web service:
  1. The user code that implements the Web service is compiled and loaded.
  2. The XMLSerializer prepares to serialize types that are used in the Web service.
Step 1 occurs only one time, and the results are cached across application domain restarts or across computers. By pre-compiling assemblies with Ngen.exe, you can prevent the Just-In-Time (JIT) debugger from compiling user code on the first method invocation at run time.

Step 2 occurs every time a new application domain starts. There is no way to cache the results.

Application domains are loaded when the aspnet_wp process starts. Microsoft ASP.NET also reloads application domains when Machine.config or Web.config settings change or when you redeploy an assembly to a bin directory. With the common language runtime, you cannot unload an assembly. Because the only mechanism to remove the assembly is to unload the application domain in which the assembly is loaded, you may still see a delay for a few seconds on the first method invocation although you have pre-compiled an assembly with Ngen.exe.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MajorLast Reviewed:4/8/2003
Keywords:kbCaching kbConfig kbPerformance kbprb KB323577