<compilation> Element

Configures all the compilation settings that ASP.NET uses.

<configuration>
   <system.web>
      <compilation>

<compilation debug="true|false" 
             batch="true|false"
             batchTimeout="number of seconds"
             defaultLanguage="language" 
             explicit="true|false" 
             maxBatchSize="maximim number of pages per 
                           batched compilation"
             maxBatchGeneratedFileSize="maximum combined size (in KB) 
                                        of the generated source file per
                                        batched compilation"
             numRecompilesBeforeAppRestart="number"
             strict="true|false" 
             tempDirectory="directory under which the ASP.NET temporary 
                            files are created">
   <compilers>
      <compiler language="language"
                extension="ext"
                type=".NET Type" 
                warningLevel="number"  
                compilerOptions="options"/>
   </compilers>

   <assemblies>
      <add assembly="assembly"/>
      <remove assembly="assembly"/>
      <clear/>
   </assemblies>
</compilation>

Optional Attributes

Attribute Option Description
debug     Specifies whether to compile retail binaries or debug binaries. The default is false.
    true Specifies compilation of debug binaries.
    false Specifies compilation of retail binaries.
defaultLanguage     Specifies the default programming language, such as "C#" or "PERL", to use in dynamic compilation files. Language names are defined using the <compiler> subtag. The default is vb.
explicit     Indicates the setting of the Microsoft Visual Basic explicit compile option. The default is true.
    true Indicates that the Visual Basic explicit compile option is enabled and that all variables must be declared using a Dim, Private, Public, or ReDim statement.
    false Indicates that the Visual Basic explicit compile option is disabled.
batch     Indicates whether batching is supported.
    true Indicates that batching is supported.
    false Indicates that batching is not supported.
batchTimeout     Indicates the time-out period, in seconds, for batch compilation. If compilation cannot be completed within the time-out period, the compiler reverts to single compilation mode for the current page.
maxBatchGeneratedFileSize     Specifies the maximum size (in KB) of the generated source files per batched compilation.
maxBatchFileSize     Specifies the maximum number of pages per batched compilation.
numRecompilesBeforeApprestart     Indicates the number of dynamic recompiles of resources that can occur before the application restarts. This attribute is supported at the global and application level but not at the directory level.
strict     Indicates the setting of the Visual Basic strict compile option.
    true Indicates that the Visual Basic strict compile option is enabled.
    false Indicates that the Visual Basic strict compile option is disabled.
tempDirectory     Specifies the directory to use for temporary file storage during compilation.

Subtags

Subtag Description
<compilers> Defines a new compiler option.
<assemblies> Specifies ASP.NET compilation processing directives.

Example

The following example configures compilation settings for an application.

<configuration>
   <system.web>
      <compilation defaultLanguage="VB"
         debug="true"
         numRecompilesBeforeAppRestart="15">
         <compilers>
            <compiler language="VB;VBScript"
               extension=".cls"
               type="Microsoft.VisualBasic.VBCodeProvider,system,     
                     Version=1.0.5000.0, Culture=neutral, 
                     PublicKeyToken=b77a5c561934e089"/>
            <compiler language="C#;Csharp"
               extension=".cs"
               type="Microsoft.CSharp.CSharpCodeProvider,system, 
                     Version=1.0.5000.0,  Culture=neutral, 
                     PublicKeyToken=b77a5c561934e089"/>
         </compilers>

         <assemblies>
            <add assembly="ADODB"/>
            <add assembly="*"/>
         </assemblies>
      </compilation>
   </system.web>
</configuration>

Requirements

Contained Within: <system.web>

Web Platform: IIS 5.0, IIS 5.1, IIS 6.0

Configuration File: Machine.config, Web.config

Configuration Section Handler: System.Web.Configuration.CompilationConfigHandler

See Also

ASP.NET Configuration | ASP.NET Settings Schema