asp.net.ph

Skip Navigation Links

<compilation> Section

ASP.NET Syntax   ASP.NET Configuration Sections


Configures all the compilation settings that ASP.NET uses.

<compilation
   debug = "true | false" 
   defaultLanguage = "language" 
   explicit = "true | false" 
   batch = "true | false"
   batchTimeout = "number" 
   numRecompilesBeforeAppRestart = "number"
   strict = "true | false">

   <compilers>
      <compiler
         language="language"
         extension = "ext"
         type = ".NET Type" 
         warningLevel = "number"  
         compilerOptions = "options" />
   </compilers>

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

   <namespaces>
      <add namespace = "namespace" />
      <remove namespace = "namespace" />
      <clear />
   </namespaces>
</compilation>

The <compilation> tag supports seven attributes and three subtags.

Attribute Option Description
debug     Specifies whether to compile retail binaries or debug binaries.
    true Specifies compilation of debug binaries.
    false Specifies compilation of retail binaries.
defaultLanguage     Provides a semicolon-separated list of language names to use in dynamic compilation files. For example, "C#; PERL".
explicit     Indicates the setting of the Microsoft® Visual Basic explicit compile option.
    true Indicates that the Visual Basic explicit compile option is enabled.
    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 for batch compilation. If compilation cannot be completed within the time-out period, the compiler reverts to single compilation mode.
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.

Subtag Description
<compilers> Encapsulates multiple <compiler> subtags.

The <compilers> subtag supports multiple <compiler> subtags that define new compiler options.

Subtag Description
<compiler> Defines a new compiler option. Any number of <compiler> tags can be used in the <compilers> section.

The <compiler> subtag supports five attributes.

Attribute Description
language Provides a semicolon-separated list of languages used in dynamic compilation files. For example, "C#; VB; JScript; PERL".
extension Provides a semicolon-separated list of file name extensions used for dynamic code-behind files. For example, ".pl; .cls; .js".
type Specifies a comma-separated class/assembly combination that indicates the .NET Framework class ( that implements ICompiler ) that is used to compile all resources that use the specified language or file name extension.
warningLevel Specifies compiler warning levels.
compilerOptions Lists additional compiler-specific options to pass during compilation.

Subtag Description
<assemblies> Specifies ASP.NET processing directives.

The <assemblies> subtag supports three subtags that act as processing directives.

Subtag Description
<add> Adds an assembly reference to use during compilation of a dynamic resource. ASP.NET automatically links this assembly to the resource when compiling each code module.

The value of <add> is an assembly name, not a DLL path. ASP.NET looks up the assembly name to find its physical DLL location. You can optionally specify the wildcard character * ( an asterisk ) to add every assembly within an application’s private assembly cache, which is located either in the \bin subdirectory of an application or in the Microsoft® .NET Framework install directory ( %windir%\Microsoft.NET\Framework\version\ ).

<remove> Removes the specified assembly reference from the compile settings. The value of <remove> must exactly match that of a previous <add> directive. Wildcard selections are not supported.
<clear> Removes all assembly references currently contained in or inherited by the specified Web.config file.

Subtag Description
<namespaces> Specifies ASP.NET processing directives.

The <namespaces> subtag supports three subtags that act as processing directives.

Subtag Description
<add> Adds an assembly reference to use during compilation of a dynamic resource. ASP.NET automatically refers to this namespace when compiling each code module.
<remove> Removes the specified namespace reference from the compile settings. The value of <remove> must exactly match that of a previous <add> directive. Wildcard selections are not supported.
<clear> Removes all namespace references currently contained in or inherited by the specified Web.config file.

Syntax 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.VB. VBCodeProvider,System" />

            <compiler language="C#;Csharp"
               extension = ".cs"
               type = "Microsoft.CSharp. CSharpCodeProvider,System" />
         </compilers>

         <assemblies>
            <add assembly = "ADODB" />
            <add assembly = "*" />
         </assemblies>

         <namespaces>
            <add namespace = "System.Web" />
            <add namespace = "System.Web.UI" />
            <add namespace = "System.Web.UI.WebControls" />
            <add namespace = "System.Web.UI.HtmlControls" />
         </namespaces>
      </compilation>
   </system.web>
</configuration>
See Also

ASP.NET Configuration   CompilationSection Class



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note