"Olorin" <fr*************@gmail.com> wrote in message news:11**********************@g14g2000cwa.googlegr oups.com...
Here's my current understanding of this 'first-invokation' problem.
Please correct me if I'm wrong.
: : This happens for all .NET apps, but we notice it more in Web APps
becaise, as the JIT compiler compiles a web app or a web service, it
must compile the code needed to serialize/deserialize all the data
types exposed by the web app or web service public API.
For a WebMethod, the Framework:
1.) Reflects against the types appearing in the signature of the method using
reflection to get all their properties (and reflects against those properties'
types if necessary, i.e. if the property had a compound type).
2.) Writes C# source code to serialize and deserialize them and saves
this into a file in your temp directory (cleans it up too, unless you set a
certain diagnostic switch instructing it to leave it there).
3.) Launches the C# compiler to compile that source code.
4.) Loads the dynamically generated assembly into memory and starts using
its serialization/deserialization class to handle the XML.
For an ASP.NET application it's a little different:
1.) Reads and parses the .ASPX file, which is a 'template' describing the
hierarchy of controls on the page and their initial settings.
2.) Writes C# source code to create the control hierarchy that fills the Page
and saves this into a file deep beneath your Temporary ASP.NET Files
directory.
3.) Launches the C# compiler to compile that source code.
4.) Saves the dynamically generated assembly alongside the source file.
It's machines writing programs for themselves and then loading systems
software like you or I would do that's the slow part.
These processes aren't known to the JIT compiler. The Serialization
process affecting WebMethods happens after code has been JIT into
machine code, only as it executes to the point where an XmlSerializer
object gets constructed for a given Type the first time. Conversely,
the ASP.NET process happens before the JIT even sees the IL in
an assembly (because the ASP.NET process is responsible for
producing the assembly the JIT receives when it doesn't already
exist or is out-of-date).
Derek Harmon