CompilationSection Klass
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Definierar konfigurationsinställningar som används för att stödja kompileringsinfrastrukturen för webbprogram. Det går inte att ärva den här klassen.
public ref class CompilationSection sealed : System::Configuration::ConfigurationSection
public sealed class CompilationSection : System.Configuration.ConfigurationSection
type CompilationSection = class
inherit ConfigurationSection
Public NotInheritable Class CompilationSection
Inherits ConfigurationSection
- Arv
Exempel
Det här exemplet visar hur du anger värden deklarativt för flera attribut i compilation avsnittet, som också kan nås som medlemmar i CompilationSection klassen.
Följande konfigurationsfilexempel visar hur du anger värden deklarativt för compilation avsnittet.
<system.web>
<compilation
tempDirectory=""
debug="False"
strict="False"
explicit="True"
batch="True"
batchTimeout="900"
maxBatchSize="1000"
maxBatchGeneratedFileSize="1000"
numRecompilesBeforeAppRestart="15"
defaultLanguage="vb"
targetFramework="4.0"
urlLinePragmas="False"
assemblyPostProcessorType="">
<assemblies>
<clear />
</assemblies>
<buildProviders>
<clear />
</buildProviders>
<expressionBuilders>
<clear />
</expressionBuilders>
</compilation>
</system.web>
Följande kodexempel visar hur du använder medlemmar i CompilationSection klassen.
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;
#endregion
namespace Samples.Aspnet.SystemWebConfiguration
{
class UsingCompilationSection
{
static void Main(string[] args)
{
try
{
// Set the path of the config file.
string configPath = "";
// Get the Web application configuration object.
Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);
// Get the section related object.
CompilationSection configSection =
(CompilationSection)config.GetSection("system.web/compilation");
// Display title and info.
Console.WriteLine("ASP.NET Configuration Info");
Console.WriteLine();
// Display Config details.
Console.WriteLine("File Path: {0}",
config.FilePath);
Console.WriteLine("Section Path: {0}",
configSection.SectionInformation.Name);
// Display Assemblies collection count.
Console.WriteLine("Assemblies Count: {0}",
configSection.Assemblies.Count);
// Display AssemblyPostProcessorType property.
Console.WriteLine("AssemblyPostProcessorType: {0}",
configSection.AssemblyPostProcessorType);
// Display Batch property.
Console.WriteLine("Batch: {0}", configSection.Batch);
// Set Batch property.
configSection.Batch = true;
// Display BatchTimeout property.
Console.WriteLine("BatchTimeout: {0}",
configSection.BatchTimeout);
// Set BatchTimeout property.
configSection.BatchTimeout = TimeSpan.FromMinutes(15);
// Display BuildProviders collection count.
Console.WriteLine("BuildProviders collection Count: {0}",
configSection.BuildProviders.Count);
// Display CodeSubDirectories collection count.
Console.WriteLine("CodeSubDirectories Count: {0}",
configSection.CodeSubDirectories.Count);
// Display Compilers collection count.
Console.WriteLine("Compilers Count: {0}",
configSection.Compilers.Count);
// Display Debug property.
Console.WriteLine("Debug: {0}",
configSection.Debug);
// Set Debug property.
configSection.Debug = false;
// Display DefaultLanguage property.
Console.WriteLine("DefaultLanguage: {0}",
configSection.DefaultLanguage);
// Set DefaultLanguage property.
configSection.DefaultLanguage = "vb";
// Display Explicit property.
Console.WriteLine("Explicit: {0}",
configSection.Explicit);
// Set Explicit property.
configSection.Explicit = true;
// Display ExpressionBuilders collection count.
Console.WriteLine("ExpressionBuilders Count: {0}",
configSection.ExpressionBuilders.Count);
// Display MaxBatchGeneratedFileSize property.
Console.WriteLine("MaxBatchGeneratedFileSize: {0}",
configSection.MaxBatchGeneratedFileSize);
// Set MaxBatchGeneratedFileSize property.
configSection.MaxBatchGeneratedFileSize = 1000;
// Display MaxBatchSize property.
Console.WriteLine("MaxBatchSize: {0}",
configSection.MaxBatchSize);
// Set MaxBatchSize property.
configSection.MaxBatchSize = 1000;
// Display NumRecompilesBeforeAppRestart property.
Console.WriteLine("NumRecompilesBeforeAppRestart: {0}",
configSection.NumRecompilesBeforeAppRestart);
// Set NumRecompilesBeforeAppRestart property.
configSection.NumRecompilesBeforeAppRestart = 15;
// Display Strict property.
Console.WriteLine("Strict: {0}",
configSection.Strict);
// Set Strict property.
configSection.Strict = false;
// Display TempDirectory property.
Console.WriteLine("TempDirectory: {0}", configSection.TempDirectory);
// Set TempDirectory property.
configSection.TempDirectory = "myTempDirectory";
// Display UrlLinePragmas property.
Console.WriteLine("UrlLinePragmas: {0}",
configSection.UrlLinePragmas);
// Set UrlLinePragmas property.
configSection.UrlLinePragmas = false;
// ExpressionBuilders Collection
int i = 1;
int j = 1;
foreach (ExpressionBuilder expressionBuilder in configSection.ExpressionBuilders)
{
Console.WriteLine();
Console.WriteLine("ExpressionBuilder {0} Details:", i);
Console.WriteLine("Type: {0}", expressionBuilder.ElementInformation.Type);
Console.WriteLine("Source: {0}", expressionBuilder.ElementInformation.Source);
Console.WriteLine("LineNumber: {0}", expressionBuilder.ElementInformation.LineNumber);
Console.WriteLine("Properties Count: {0}", expressionBuilder.ElementInformation.Properties.Count);
j = 1;
foreach (PropertyInformation propertyItem in expressionBuilder.ElementInformation.Properties)
{
Console.WriteLine("Property {0} Name: {1}", j, propertyItem.Name);
Console.WriteLine("Property {0} Value: {1}", j, propertyItem.Value);
j++;
}
i++;
}
// Update if not locked.
if (!configSection.SectionInformation.IsLocked)
{
config.Save();
Console.WriteLine("** Configuration updated.");
}
else
{
Console.WriteLine("** Could not update, section is locked.");
}
}
catch (Exception e)
{
// Unknown error.
Console.WriteLine(e.ToString());
}
// Display and wait
Console.ReadLine();
}
}
}
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Web
Imports System.Web.Configuration
Namespace Samples.Aspnet.SystemWebConfiguration
Class UsingRoleManagerSection
Public Shared Sub Main()
Try
' Set the path of the config file.
Dim configPath As String = ""
' Get the Web application configuration object.
Dim config As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration(configPath)
' Get the section related object.
Dim configSection As System.Web.Configuration.CompilationSection = _
CType(config.GetSection("system.web/compilation"), _
System.Web.Configuration.CompilationSection)
' Display title and info.
Console.WriteLine("ASP.NET Configuration Info")
Console.WriteLine()
' Display Config details.
Console.WriteLine("File Path: {0}", _
config.FilePath)
Console.WriteLine("Section Path: {0}", _
configSection.SectionInformation.Name)
' Display Assemblies collection count.
Console.WriteLine("Assemblies Count: {0}", _
configSection.Assemblies.Count)
' Display AssemblyPostProcessorType property.
Console.WriteLine("AssemblyPostProcessorType: {0}", _
configSection.AssemblyPostProcessorType)
' Display Batch property.
Console.WriteLine("Batch: {0}", _
configSection.Batch)
' Set Batch property.
configSection.Batch = True
' Display BatchTimeout property.
Console.WriteLine("BatchTimeout: {0}", _
configSection.BatchTimeout)
' Set BatchTimeout property.
configSection.BatchTimeout = TimeSpan.FromMinutes(15)
' Display BuildProviders collection count.
Console.WriteLine("BuildProviders collection count: {0}", _
configSection.BuildProviders.Count)
' Display CodeSubDirectories property.
Console.WriteLine("CodeSubDirectories: {0}", _
configSection.CodeSubDirectories.Count)
' Display Compilers property.
Console.WriteLine("Compilers: {0}", _
configSection.Compilers.Count)
' Display Debug property.
Console.WriteLine("Debug: {0}", _
configSection.Debug)
' Set Debug property.
configSection.Debug = False
' Display DefaultLanguage property.
Console.WriteLine("DefaultLanguage: {0}", _
configSection.DefaultLanguage)
' Set DefaultLanguage property.
configSection.DefaultLanguage = "vb"
' Display Explicit property.
Console.WriteLine("Explicit: {0}", _
configSection.Explicit)
' Set Explicit property.
configSection.Explicit = True
' Display ExpressionBuilders collection count.
Console.WriteLine("ExpressionBuilders Count: {0}", _
configSection.ExpressionBuilders.Count)
' Display MaxBatchGeneratedFileSize property.
Console.WriteLine("MaxBatchGeneratedFileSize: {0}", _
configSection.MaxBatchGeneratedFileSize)
' Set MaxBatchGeneratedFileSize property.
configSection.MaxBatchGeneratedFileSize = 1000
' Display MaxBatchSize property.
Console.WriteLine("MaxBatchSize: {0}", _
configSection.MaxBatchSize)
' Set MaxBatchSize property.
configSection.MaxBatchSize = 1000
' Display NumRecompilesBeforeAppRestart property.
Console.WriteLine("NumRecompilesBeforeAppRestart: {0}", _
configSection.NumRecompilesBeforeAppRestart)
' Set NumRecompilesBeforeAppRestart property.
configSection.NumRecompilesBeforeAppRestart = 15
' Display Strict property.
Console.WriteLine("Strict: {0}", _
configSection.Strict)
' Set Strict property.
configSection.Strict = False
' Display TempDirectory property.
Console.WriteLine("TempDirectory: {0}", _
configSection.TempDirectory)
' Set TempDirectory property.
configSection.TempDirectory = "myTempDirectory"
' Display UrlLinePragmas property.
Console.WriteLine("UrlLinePragmas: {0}", _
configSection.UrlLinePragmas)
' Set UrlLinePragmas property.
configSection.UrlLinePragmas = False
' ExpressionBuilders Collection
Dim i = 1
Dim j = 1
For Each expressionBuilder As ExpressionBuilder In configSection.ExpressionBuilders()
Console.WriteLine()
Console.WriteLine("ExpressionBuilder {0} Details:", i)
Console.WriteLine("Type: {0}", expressionBuilder.ElementInformation.Type)
Console.WriteLine("Source: {0}", expressionBuilder.ElementInformation.Source)
Console.WriteLine("LineNumber: {0}", expressionBuilder.ElementInformation.LineNumber)
Console.WriteLine("Properties Count: {0}", expressionBuilder.ElementInformation.Properties.Count)
j = 1
For Each propertyItem As PropertyInformation In expressionBuilder.ElementInformation.Properties
Console.WriteLine("Property {0} Name: {1}", j, propertyItem.Name)
Console.WriteLine("Property {0} Value: {1}", j, propertyItem.Value)
j = j + 1
Next
i = i + 1
Next
' Update if not locked.
If Not configSection.SectionInformation.IsLocked Then
config.Save()
Console.WriteLine("** Configuration updated.")
Else
Console.WriteLine("** Could not update, section is locked.")
End If
Catch e As Exception
' Unknown error.
Console.WriteLine(e.ToString())
End Try
' Display and wait
Console.ReadLine()
End Sub
End Class
End Namespace
Kommentarer
Klassen CompilationSection ger ett sätt att programmatiskt komma åt och ändra innehållet i compilation avsnittet i konfigurationsfilen.
Konstruktorer
| Name | Description |
|---|---|
| CompilationSection() |
Initierar en ny instans av CompilationSection klassen med hjälp av standardinställningar. |
Egenskaper
| Name | Description |
|---|---|
| Assemblies |
AssemblyCollection Hämtar .CompilationSection |
| AssemblyPostProcessorType |
Hämtar eller anger ett värde som anger ett kompileringssteg efter processen för en sammansättning. |
| Batch |
Hämtar eller anger ett värde som anger om batchkompilering görs. |
| BatchTimeout |
Hämtar eller anger tidsgränsen i sekunder för batchkompilering. |
| BuildProviders |
BuildProviderCollection Hämtar klassens CompilationSection samling. |
| CodeSubDirectories | |
| Compilers |
CompilerCollection Hämtar klassens CompilationSection samling. |
| ControlBuilderInterceptorType |
Hämtar eller anger en sträng som representerar den objekttyp som används för att fånga upp ett ControlBuilder objekt och konfigurera en container. |
| CurrentConfiguration |
Hämtar en referens till den översta instansen Configuration som representerar konfigurationshierarkin som den aktuella ConfigurationElement instansen tillhör. (Ärvd från ConfigurationElement) |
| Debug |
Hämtar eller anger ett värde som anger om du vill kompilera versionsbinärfiler eller felsöka binärfiler. |
| DefaultLanguage |
Hämtar eller anger det standardprogrammeringsspråk som ska användas i dynamiska kompileringsfiler. |
| DisableObsoleteWarnings |
Hämtar eller anger om konfigurationsvärdet "disableObsoleteWarnings" i avsnittet Kompilering har angetts. |
| ElementInformation |
Hämtar ett ElementInformation objekt som innehåller den icke-anpassningsbara informationen och funktionerna i ConfigurationElement objektet. (Ärvd från ConfigurationElement) |
| ElementProperty |
Hämtar objektet ConfigurationElementProperty som representerar ConfigurationElement själva objektet. (Ärvd från ConfigurationElement) |
| EnablePrefetchOptimization |
Hämtar eller anger ett värde som anger om ett ASP.NET program kan dra nytta av Windows 8 prefetch-funktioner. |
| EvaluationContext |
Hämtar ContextInformation-objektet för ConfigurationElement-objektet. (Ärvd från ConfigurationElement) |
| Explicit |
Hämtar eller anger ett värde som anger om du vill använda kompileringsalternativet Microsoft Visual Basic |
| ExpressionBuilders | |
| FolderLevelBuildProviders |
FolderLevelBuildProviderCollection Hämtar samlingen av CompilationSection klassen, som representerar de byggproviders som används under kompilering. |
| HasContext |
Hämtar ett värde som anger om egenskapen CurrentConfiguration är |
| Item[ConfigurationProperty] |
Hämtar eller anger en egenskap eller ett attribut för det här konfigurationselementet. (Ärvd från ConfigurationElement) |
| Item[String] |
Hämtar eller anger en egenskap, ett attribut eller ett underordnat element i det här konfigurationselementet. (Ärvd från ConfigurationElement) |
| LockAllAttributesExcept |
Hämtar samlingen med låsta attribut. (Ärvd från ConfigurationElement) |
| LockAllElementsExcept |
Hämtar samlingen med låsta element. (Ärvd från ConfigurationElement) |
| LockAttributes |
Hämtar samlingen med låsta attribut. (Ärvd från ConfigurationElement) |
| LockElements |
Hämtar samlingen med låsta element. (Ärvd från ConfigurationElement) |
| LockItem |
Hämtar eller anger ett värde som anger om elementet är låst. (Ärvd från ConfigurationElement) |
| MaxBatchGeneratedFileSize |
Hämtar eller anger den maximala kombinerade storleken på de genererade källfilerna per batchkompilering. |
| MaxBatchSize |
Hämtar eller anger det maximala antalet sidor per batchkompilering. |
| MaxConcurrentCompilations |
Hämtar eller anger om konfigurationsvärdet "maxConcurrentCompilations" i avsnittet Kompilering har angetts. |
| NumRecompilesBeforeAppRestart |
Hämtar eller anger antalet dynamiska omkompileringar av resurser som kan inträffa innan programmet startas om. |
| OptimizeCompilations |
Hämtar eller anger ett värde som anger om kompilering måste optimeras. |
| ProfileGuidedOptimizations |
Hämtar eller anger ett värde som anger om programmet är optimerat för den distribuerade miljön. |
| Properties |
Hämtar samlingen med egenskaper. (Ärvd från ConfigurationElement) |
| SectionInformation |
Hämtar ett SectionInformation objekt som innehåller den icke-anpassningsbara informationen och funktionerna i ConfigurationSection objektet. (Ärvd från ConfigurationSection) |
| Strict |
Hämtar eller anger kompileringsalternativet Visual Basic |
| TargetFramework |
Hämtar eller anger den version av .NET Framework som webbplatsen riktar in sig på. |
| TempDirectory |
Hämtar eller anger ett värde som anger vilken katalog som ska användas för tillfällig fillagring under kompilering. |
| UrlLinePragmas |
Hämtar eller anger ett värde som anger om instruktioner till kompilatorn använder fysiska sökvägar eller URL:er. |
Metoder
| Name | Description |
|---|---|
| DeserializeElement(XmlReader, Boolean) |
Läser XML från konfigurationsfilen. (Ärvd från ConfigurationElement) |
| DeserializeSection(XmlReader) |
Läser XML från konfigurationsfilen. (Ärvd från ConfigurationSection) |
| Equals(Object) |
Jämför den aktuella ConfigurationElement instansen med det angivna objektet. (Ärvd från ConfigurationElement) |
| GetHashCode() |
Hämtar ett unikt värde som representerar den aktuella ConfigurationElement instansen. (Ärvd från ConfigurationElement) |
| GetRuntimeObject() |
Returnerar ett anpassat objekt när det åsidosättas i en härledd klass. (Ärvd från ConfigurationSection) |
| GetTransformedAssemblyString(String) |
Returnerar den transformerade versionen av det angivna sammansättningsnamnet. (Ärvd från ConfigurationElement) |
| GetTransformedTypeString(String) |
Returnerar den transformerade versionen av det angivna typnamnet. (Ärvd från ConfigurationElement) |
| GetType() |
Hämtar den aktuella instansen Type . (Ärvd från Object) |
| Init() |
Anger objektets ConfigurationElement ursprungliga tillstånd. (Ärvd från ConfigurationElement) |
| InitializeDefault() |
Används för att initiera en standarduppsättning med värden för ConfigurationElement objektet. (Ärvd från ConfigurationElement) |
| IsModified() |
Anger om det här konfigurationselementet har ändrats sedan det senast sparades eller lästes in när det implementerades i en härledd klass. (Ärvd från ConfigurationSection) |
| IsReadOnly() |
Hämtar ett värde som anger om objektet ConfigurationElement är skrivskyddat. (Ärvd från ConfigurationElement) |
| ListErrors(IList) |
Lägger till felen invalid-property i det här ConfigurationElement objektet, och i alla underelement, i den överförda listan. (Ärvd från ConfigurationElement) |
| MemberwiseClone() |
Skapar en ytlig kopia av den aktuella Object. (Ärvd från Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Hämtar ett värde som anger om ett okänt attribut påträffas under deserialiseringen. (Ärvd från ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Hämtar ett värde som anger om ett okänt element påträffas under deserialiseringen. (Ärvd från ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Utlöser ett undantag när en obligatorisk egenskap inte hittas. (Ärvd från ConfigurationElement) |
| PostDeserialize() |
Anropas efter deserialisering. (Ärvd från ConfigurationElement) |
| PreSerialize(XmlWriter) |
Anropas före serialisering. (Ärvd från ConfigurationElement) |
| Reset(ConfigurationElement) |
Återställer objektets interna tillstånd ConfigurationElement , inklusive låsen och egenskapssamlingarna. (Ärvd från ConfigurationElement) |
| ResetModified() |
Återställer värdet för metoden till IsModified() när den |
| SerializeElement(XmlWriter, Boolean) |
Skriver innehållet i det här konfigurationselementet till konfigurationsfilen när det implementeras i en härledd klass. (Ärvd från ConfigurationElement) |
| SerializeSection(ConfigurationElement, String, ConfigurationSaveMode) |
Skapar en XML-sträng som innehåller en icke-komprimerad vy av ConfigurationSection objektet som ett enda avsnitt för att skriva till en fil. (Ärvd från ConfigurationSection) |
| SerializeToXmlElement(XmlWriter, String) |
Skriver de yttre taggarna för det här konfigurationselementet till konfigurationsfilen när det implementeras i en härledd klass. (Ärvd från ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Anger en egenskap till det angivna värdet. (Ärvd från ConfigurationElement) |
| SetReadOnly() |
Anger egenskapen IsReadOnly() för ConfigurationElement objektet och alla underelement. (Ärvd från ConfigurationElement) |
| ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) |
Anger om det angivna elementet ska serialiseras när konfigurationsobjekthierarkin serialiseras för den angivna målversionen av .NET Framework. (Ärvd från ConfigurationSection) |
| ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement) |
Anger om den angivna egenskapen ska serialiseras när konfigurationsobjekthierarkin serialiseras för den angivna målversionen av .NET Framework. (Ärvd från ConfigurationSection) |
| ShouldSerializeSectionInTargetVersion(FrameworkName) |
Anger om den aktuella ConfigurationSection-instansen ska serialiseras när konfigurationsobjekthierarkin serialiseras för den angivna målversionen av .NET Framework. (Ärvd från ConfigurationSection) |
| ToString() |
Returnerar en sträng som representerar det aktuella objektet. (Ärvd från Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Ändrar objektet ConfigurationElement för att ta bort alla värden som inte ska sparas. (Ärvd från ConfigurationElement) |