CompilationSection Klasse
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Definiert Konfigurationseinstellungen, die zur Unterstützung der Kompilierungsinfrastruktur von Webanwendungen verwendet werden. Diese Klasse kann nicht vererbt werden.
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
- Vererbung
Beispiele
In diesem Beispiel wird veranschaulicht, wie Werte deklarativ für mehrere Attribute des compilation Abschnitts angegeben werden, auf die auch als Member der CompilationSection Klasse zugegriffen werden kann.
Das folgende Konfigurationsdateibeispiel zeigt, wie Werte deklarativ für den compilation Abschnitt angegeben werden.
<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>
Im folgenden Codebeispiel wird die Verwendung von Membern der CompilationSection Klasse veranschaulicht.
#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
Hinweise
Die CompilationSection Klasse bietet eine Möglichkeit, programmgesteuert auf den Inhalt des compilation Abschnitts der Konfigurationsdatei zuzugreifen und sie zu ändern.
Konstruktoren
| Name | Beschreibung |
|---|---|
| CompilationSection() |
Initialisiert eine neue Instanz der CompilationSection Klasse mithilfe von Standardeinstellungen. |
Eigenschaften
| Name | Beschreibung |
|---|---|
| Assemblies |
Ruft den AssemblyCollection der .CompilationSection |
| AssemblyPostProcessorType |
Dient zum Abrufen oder Festlegen eines Werts, der einen Kompilierungsschritt nach dem Prozess für eine Assembly angibt. |
| Batch |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob die Batchkompilierung versucht wird. |
| BatchTimeout |
Ruft den Timeoutzeitraum für die Batchkompilierung in Sekunden ab oder legt diese fest. |
| BuildProviders |
Ruft die BuildProviderCollection Auflistung der CompilationSection Klasse ab. |
| CodeSubDirectories |
Ruft den CodeSubDirectoriesCollection der .CompilationSection |
| Compilers |
Ruft die CompilerCollection Auflistung der CompilationSection Klasse ab. |
| ControlBuilderInterceptorType |
Dient zum Abrufen oder Festlegen einer Zeichenfolge, die den Objekttyp darstellt, der verwendet wird, um ein ControlBuilder Objekt abzufangen und einen Container zu konfigurieren. |
| CurrentConfiguration |
Ruft einen Verweis auf die Instanz der obersten Ebene Configuration ab, die die Konfigurationshierarchie darstellt, zu der die aktuelle ConfigurationElement Instanz gehört. (Geerbt von ConfigurationElement) |
| Debug |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob Versionsbinärdateien kompiliert oder Binärdateien gedebuggt werden sollen. |
| DefaultLanguage |
Ruft die Standardprogrammiersprache ab, die in Dynamischen Kompilierungsdateien verwendet werden soll, oder legt sie fest. |
| DisableObsoleteWarnings |
Ruft ab oder legt fest, ob der Konfigurationswert "disableObsoleteWarnings" im Abschnitt "Kompilierung" festgelegt ist. |
| ElementInformation |
Ruft ein ElementInformation Objekt ab, das die nicht anpassbaren Informationen und Funktionen des ConfigurationElement Objekts enthält. (Geerbt von ConfigurationElement) |
| ElementProperty |
Ruft das ConfigurationElementProperty Objekt ab, das das ConfigurationElement Objekt selbst darstellt. (Geerbt von ConfigurationElement) |
| EnablePrefetchOptimization |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob eine ASP.NET Anwendung Windows 8 Prefetch-Funktionalität nutzen kann. |
| EvaluationContext |
Ruft das ContextInformation-Objekt für das ConfigurationElement-Objekt ab. (Geerbt von ConfigurationElement) |
| Explicit |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob die Kompilierungsoption von Microsoft Visual Basic |
| ExpressionBuilders |
Ruft den ExpressionBuilderCollection der .CompilationSection |
| FolderLevelBuildProviders |
Ruft die FolderLevelBuildProviderCollection Auflistung der CompilationSection Klasse ab, die die Buildanbieter darstellt, die während der Kompilierung verwendet werden. |
| HasContext |
Ruft einen Wert ab, der angibt, ob die CurrentConfiguration Eigenschaft ist |
| Item[ConfigurationProperty] |
Dient zum Abrufen oder Festlegen einer Eigenschaft oder eines Attributs dieses Konfigurationselements. (Geerbt von ConfigurationElement) |
| Item[String] |
Dient zum Abrufen oder Festlegen einer Eigenschaft, eines Attributs oder eines untergeordneten Elements dieses Konfigurationselements. (Geerbt von ConfigurationElement) |
| LockAllAttributesExcept |
Ruft die Auflistung gesperrter Attribute ab. (Geerbt von ConfigurationElement) |
| LockAllElementsExcept |
Ruft die Auflistung gesperrter Elemente ab. (Geerbt von ConfigurationElement) |
| LockAttributes |
Ruft die Auflistung gesperrter Attribute ab. (Geerbt von ConfigurationElement) |
| LockElements |
Ruft die Auflistung gesperrter Elemente ab. (Geerbt von ConfigurationElement) |
| LockItem |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob das Element gesperrt ist. (Geerbt von ConfigurationElement) |
| MaxBatchGeneratedFileSize |
Ruft die maximale kombinierte Größe der generierten Quelldateien pro Batchkompilierung ab oder legt diese fest. |
| MaxBatchSize |
Ruft die maximale Anzahl von Seiten pro Batchkompilierung ab oder legt sie fest. |
| MaxConcurrentCompilations |
Ruft ab oder legt fest, ob der Konfigurationswert "maxConcurrentCompilations" im Kompilierungsbereich festgelegt ist. |
| NumRecompilesBeforeAppRestart |
Ruft die Anzahl der dynamischen Neukompilierungen von Ressourcen ab, die vor dem Neustart der Anwendung auftreten können, oder legt diese fest. |
| OptimizeCompilations |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob die Kompilierung optimiert werden muss. |
| ProfileGuidedOptimizations |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob die Anwendung für die bereitgestellte Umgebung optimiert ist. |
| Properties |
Ruft die Auflistung von Eigenschaften ab. (Geerbt von ConfigurationElement) |
| SectionInformation |
Ruft ein SectionInformation Objekt ab, das die nicht anpassbaren Informationen und Funktionen des ConfigurationSection Objekts enthält. (Geerbt von ConfigurationSection) |
| Strict |
Ruft die Visual Basic-Kompilierungsoption |
| TargetFramework |
Ruft die Version des .NET Frameworks ab, auf das die Website ausgerichtet ist, oder legt diese fest. |
| TempDirectory |
Dient zum Abrufen oder Festlegen eines Werts, der das Verzeichnis angibt, das während der Kompilierung für den temporären Dateispeicher verwendet werden soll. |
| UrlLinePragmas |
Dient zum Abrufen oder Festlegen eines Werts, der angibt, ob Anweisungen für den Compiler physische Pfade oder URLs verwenden. |
Methoden
| Name | Beschreibung |
|---|---|
| DeserializeElement(XmlReader, Boolean) |
Liest XML aus der Konfigurationsdatei. (Geerbt von ConfigurationElement) |
| DeserializeSection(XmlReader) |
Liest XML aus der Konfigurationsdatei. (Geerbt von ConfigurationSection) |
| Equals(Object) |
Vergleicht die aktuelle ConfigurationElement Instanz mit dem angegebenen Objekt. (Geerbt von ConfigurationElement) |
| GetHashCode() |
Ruft einen eindeutigen Wert ab, der die aktuelle ConfigurationElement Instanz darstellt. (Geerbt von ConfigurationElement) |
| GetRuntimeObject() |
Gibt ein benutzerdefiniertes Objekt zurück, wenn es in einer abgeleiteten Klasse überschrieben wird. (Geerbt von ConfigurationSection) |
| GetTransformedAssemblyString(String) |
Gibt die transformierte Version des angegebenen Assemblynamens zurück. (Geerbt von ConfigurationElement) |
| GetTransformedTypeString(String) |
Gibt die transformierte Version des angegebenen Typnamens zurück. (Geerbt von ConfigurationElement) |
| GetType() |
Ruft die Type der aktuellen Instanz ab. (Geerbt von Object) |
| Init() |
Legt das ConfigurationElement Objekt auf seinen Anfangszustand fest. (Geerbt von ConfigurationElement) |
| InitializeDefault() |
Wird verwendet, um einen Standardsatz von Werten für das ConfigurationElement Objekt zu initialisieren. (Geerbt von ConfigurationElement) |
| IsModified() |
Gibt an, ob dieses Konfigurationselement seit dem letzten Speichern oder Laden geändert wurde, wenn es in einer abgeleiteten Klasse implementiert wurde. (Geerbt von ConfigurationSection) |
| IsReadOnly() |
Ruft einen Wert ab, der angibt, ob das ConfigurationElement Objekt schreibgeschützt ist. (Geerbt von ConfigurationElement) |
| ListErrors(IList) |
Fügt der übergebenen Liste die Fehler der ungültigen Eigenschaft in diesem ConfigurationElement Objekt und in allen Unterelementen hinzu. (Geerbt von ConfigurationElement) |
| MemberwiseClone() |
Erstellt eine flache Kopie der aktuellen Object. (Geerbt von Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Ruft einen Wert ab, der angibt, ob während der Deserialisierung ein unbekanntes Attribut gefunden wird. (Geerbt von ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Ruft einen Wert ab, der angibt, ob während der Deserialisierung ein unbekanntes Element auftritt. (Geerbt von ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Löst eine Ausnahme aus, wenn eine erforderliche Eigenschaft nicht gefunden wird. (Geerbt von ConfigurationElement) |
| PostDeserialize() |
Wird nach der Deserialisierung aufgerufen. (Geerbt von ConfigurationElement) |
| PreSerialize(XmlWriter) |
Wird vor der Serialisierung aufgerufen. (Geerbt von ConfigurationElement) |
| Reset(ConfigurationElement) |
Setzt den internen Zustand des ConfigurationElement Objekts zurück, einschließlich der Sperren und der Eigenschaftenauflistungen. (Geerbt von ConfigurationElement) |
| ResetModified() |
Setzt den Wert der IsModified() Methode zurück, wenn |
| SerializeElement(XmlWriter, Boolean) |
Schreibt den Inhalt dieses Konfigurationselements in die Konfigurationsdatei, wenn es in einer abgeleiteten Klasse implementiert wird. (Geerbt von ConfigurationElement) |
| SerializeSection(ConfigurationElement, String, ConfigurationSaveMode) |
Erstellt eine XML-Zeichenfolge, die eine nicht zusammengeführte Ansicht des ConfigurationSection Objekts als einzelner Abschnitt enthält, um in eine Datei zu schreiben. (Geerbt von ConfigurationSection) |
| SerializeToXmlElement(XmlWriter, String) |
Schreibt die äußeren Tags dieses Konfigurationselements in die Konfigurationsdatei, wenn sie in einer abgeleiteten Klasse implementiert wird. (Geerbt von ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Legt eine Eigenschaft auf den angegebenen Wert fest. (Geerbt von ConfigurationElement) |
| SetReadOnly() |
Legt die IsReadOnly() Eigenschaft für das ConfigurationElement Objekt und alle Unterelemente fest. (Geerbt von ConfigurationElement) |
| ShouldSerializeElementInTargetVersion(ConfigurationElement, String, FrameworkName) |
Gibt an, ob das angegebene Element serialisiert werden soll, wenn die Konfigurationsobjekthierarchie für die angegebene Zielversion des .NET Framework serialisiert wird. (Geerbt von ConfigurationSection) |
| ShouldSerializePropertyInTargetVersion(ConfigurationProperty, String, FrameworkName, ConfigurationElement) |
Gibt an, ob die angegebene Eigenschaft serialisiert werden soll, wenn die Konfigurationsobjekthierarchie für die angegebene Zielversion des .NET Framework serialisiert wird. (Geerbt von ConfigurationSection) |
| ShouldSerializeSectionInTargetVersion(FrameworkName) |
Gibt an, ob die aktuelle ConfigurationSection-Instanz serialisiert werden soll, wenn die Konfigurationsobjekthierarchie für die angegebene Zielversion des .NET Framework serialisiert wird. (Geerbt von ConfigurationSection) |
| ToString() |
Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt. (Geerbt von Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Ändert das ConfigurationElement Objekt, um alle Werte zu entfernen, die nicht gespeichert werden sollen. (Geerbt von ConfigurationElement) |