A CodeDomProvider can be used to create and retrieve instances of code generators and code compilers. Code generators can be used to generate code in a particular language, and code compilers can be used to compile code into assemblies.
Note: |
|---|
In the
.NET Framework version 2.0, the methods made available in the code generator and code compiler are available directly from the code provider. You do not need to call CreateGenerator or CreateCompiler to access the methods, and those methods are marked as obsolete. This applies to preexisting as well as new code provider implementations.
|
A CodeDomProvider implementation typically provides code generation and/or code compilation interfaces for generating code and managing compilation for a single programming language. Several languages are supported by CodeDomProvider implementations that ship with the Windows Software Development Kit (SDK). These languages include C#, Visual Basic, C++, J#, and JScript. Developers or compiler vendors can implement the ICodeGenerator and ICodeCompiler interfaces and provide a CodeDomProvider that extends CodeDom support to other programming languages.
The <system.codedom> Element in the machine configuration file (Machine.config) provides a mechanism for developers and compiler vendors to add configuration settings for additional CodeDomProvider implementations.
The CodeDomProvider class provides static methods to discover and enumerate the CodeDomProvider implementations on a computer. The GetAllCompilerInfo method returns the settings for all CodeDomProvider implementations on a computer. The GetCompilerInfo method returns the settings for a specific CodeDomProvider implementation, based on the programming language name. The CreateProvider method returns an instance of a CodeDomProvider implementation for a specific language.
For more details on language provider settings in the configuration file, see Compiler and Language Provider Settings Schema.
Note: |
|---|
This class makes a link demand and an inheritance demand at the class level. A
SecurityException is thrown if 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.
|
Notes to Inheritors:
In the .NET Framework versions 1.0 and 1.1, code providers consist of implementations of CodeDomProvider, ICodeGenerator, ICodeParser, and ICodeCompiler. In the .NET Framework 2.0, the CreateGenerator, CreateParser, and CreateCompiler methods are obsolete, and the methods of ICodeGenerator and ICodeCompiler are directly available in the CodeDomProvider class. You should override those methods in your code provider implementation and not call the base methods.