CSharpCodeProvider Class
Provides access to instances of the C# code generator and code compiler.
System::MarshalByRefObject
System.ComponentModel::Component
System.CodeDom.Compiler::CodeDomProvider
Microsoft.CSharp::CSharpCodeProvider
Assembly: System (in System.dll)
The CSharpCodeProvider type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CSharpCodeProvider() | Initializes a new instance of the CSharpCodeProvider class. |
![]() | CSharpCodeProvider(IDictionary<String, String>) | Initializes a new instance of the CSharpCodeProvider class by using the specified provider options. |
| Name | Description | |
|---|---|---|
![]() | CanRaiseEvents | Gets a value indicating whether the component can raise an event. (Inherited from Component.) |
![]() | Container | Gets the IContainer that contains the Component. (Inherited from Component.) |
![]() | DesignMode | Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component.) |
![]() | Events | Gets the list of event handlers that are attached to this Component. (Inherited from Component.) |
![]() | FileExtension | Gets the file name extension to use when creating source code files. (Overrides CodeDomProvider::FileExtension.) |
![]() | LanguageOptions | Gets a language features identifier. (Inherited from CodeDomProvider.) |
![]() | Site | Gets or sets the ISite of the Component. (Inherited from Component.) |
| Name | Description | |
|---|---|---|
![]() | CompileAssemblyFromDom | Compiles an assembly based on the System.CodeDom trees contained in the specified array of CodeCompileUnit objects, using the specified compiler settings. (Inherited from CodeDomProvider.) |
![]() | CompileAssemblyFromFile | Compiles an assembly from the source code contained in the specified files, using the specified compiler settings. (Inherited from CodeDomProvider.) |
![]() | CompileAssemblyFromSource | Compiles an assembly from the specified array of strings containing source code, using the specified compiler settings. (Inherited from CodeDomProvider.) |
![]() | CreateCompiler | Obsolete. Gets an instance of the C# code compiler. (Overrides CodeDomProvider::CreateCompiler().) |
![]() | CreateEscapedIdentifier | Creates an escaped identifier for the specified value. (Inherited from CodeDomProvider.) |
![]() | CreateGenerator() | Obsolete. Gets an instance of the C# code generator. (Overrides CodeDomProvider::CreateGenerator().) |
![]() | CreateGenerator(String) | When overridden in a derived class, creates a new code generator using the specified file name for output. (Inherited from CodeDomProvider.) |
![]() | CreateGenerator(TextWriter) | When overridden in a derived class, creates a new code generator using the specified TextWriter for output. (Inherited from CodeDomProvider.) |
![]() | CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) |
![]() | CreateParser | Obsolete. When overridden in a derived class, creates a new code parser. (Inherited from CodeDomProvider.) |
![]() | CreateValidIdentifier | Creates a valid identifier for the specified value. (Inherited from CodeDomProvider.) |
![]() | Dispose() | Releases all resources used by the Component. (Inherited from Component.) |
![]() | Dispose(Boolean) | Releases the unmanaged resources used by the Component and optionally releases the managed resources. (Inherited from Component.) |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.) |
![]() | GenerateCodeFromCompileUnit | Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and sends it to the specified text writer, using the specified options. (Inherited from CodeDomProvider.) |
![]() | GenerateCodeFromExpression | Generates code for the specified Code Document Object Model (CodeDOM) expression and sends it to the specified text writer, using the specified options. (Inherited from CodeDomProvider.) |
![]() | GenerateCodeFromMember | Generates code for the specified class member using the specified text writer and code generator options. (Overrides CodeDomProvider::GenerateCodeFromMember(CodeTypeMember, TextWriter, CodeGeneratorOptions).) |
![]() | GenerateCodeFromNamespace | Generates code for the specified Code Document Object Model (CodeDOM) namespace and sends it to the specified text writer, using the specified options. (Inherited from CodeDomProvider.) |
![]() | GenerateCodeFromStatement | Generates code for the specified Code Document Object Model (CodeDOM) statement and sends it to the specified text writer, using the specified options. (Inherited from CodeDomProvider.) |
![]() | GenerateCodeFromType | Generates code for the specified Code Document Object Model (CodeDOM) type declaration and sends it to the specified text writer, using the specified options. (Inherited from CodeDomProvider.) |
![]() | GetConverter | Gets a TypeConverter for the specified type of object. (Overrides CodeDomProvider::GetConverter(Type).) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | GetService | Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetTypeOutput | Gets the type indicated by the specified CodeTypeReference. (Inherited from CodeDomProvider.) |
![]() | InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) |
![]() | IsValidIdentifier | Returns a value that indicates whether the specified value is a valid identifier for the current language. (Inherited from CodeDomProvider.) |
![]() | MemberwiseClone() | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) |
![]() | Parse | Compiles the code read from the specified text stream into a CodeCompileUnit. (Inherited from CodeDomProvider.) |
![]() | Supports | Returns a value indicating whether the specified code generation support is provided. (Inherited from CodeDomProvider.) |
![]() | ToString | Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.) |
This class provides methods that can be used to retrieve instances of the C# ICodeGenerator and ICodeCompiler implementations.
Note |
|---|
This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands. |
The following example uses either the C# or Visual Basic code provider to compile a source file. The example checks the input file extension and uses the corresponding CSharpCodeProvider or VBCodeProvider for compilation. The input file is compiled into an executable file, and any compilation errors are displayed to the console.
- SecurityAction::LinkDemand
for full trust for the immediate caller. This class cannot be used by partially trusted code.
- SecurityAction::InheritanceDemand
for full trust for inheritors. This class cannot be inherited by partially trusted code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
