Search code examples
asp.netprecompile

Precompile asp.net application / webpart for WSS / SharePoint


I have built a few custom applications that run on WSS 3 using the Visual Studio 2010 Web application template. When I compile the application, Visual Studio creates the assembly file in the bin directory which I copy over later to the production server (another machine) with WSS 3. The compiled application dll file is copied into the bin folder inside the virtual directory of WSS and runs fine in there.

As the project requirements / applications grew over time I now face the problem that the first hit on the assembly triggers dynamic compilation which I would like to avoid.

Even if applications are running fine I would like to use the asp precompiler on my development machine in order to reduce the delay when the page is first requested.

I have used the following command to precompile the entire Web Application:

aspnet_precompile -v / -p PATH_TO_WEB_APPLICATION C:\WebApp -errorstack

The compilation runs fine without any errors and I end up with a couple of .compiled files and also a Web_App_xxxxx.dll file inside the C:\WebApp\bin folder.

From here onwards I am a bit lost on how to proceed.

Could you please give me some advise to which folder I need to copy the compiled files on the production server ?

Do they need to go into the bin folder on the server or better into the folder where the aspx pages are located?

Additionally I would like to know if I can precompile the Web application on a development machine without the IIS metabase using the -v and -p switch and later use it inside WSS?

I copied all files from the C:\WebApp\bin folder to the server bin folder but unfortunately the csc compilation process still kicks in when looking with process monitor at the server events.

Cheers,

Mathias


Solution

  • I found an answer to this precompilation question:

    I thought the first hit on the application page takes a long time because asp.net needs to compile it and I can save some time by precompiling. The application runs inside the WSS context and enables the user to go to a web form and update through the form his/her Active Directory profile. The Exchange global address list is also updated on the Exchange forest so the changes are visible through the Outlook address list and also on Communicator.

    The complete solution code with reports etc is around 6000 lines of C# code.

    My assumption regarding slow compilation due to the amount of lines was wrong.

    I downloaded the following hotfix for asp.net: http://support.microsoft.com/kb/961884

    and set optimizeCompilations="true" in the web.config as explained here:

    http://blogs.msdn.com/b/davidebb/archive/2009/04/15/a-new-flag-to-optimize-asp-net-compilation-behavior.aspx

    http://www.paulliebrand.com/2009/09/18/sharepoint-development-to-bin-folder-and-extremely-slow-render-initial-render-times-solution/

    Now the first hit on the application is much faster.

    Many thanks,

    Mathias