System.Web.Compilation.AssemblyBuilder.CreateCodeFile Method

Allows a build provider to create a temporary source file, and include the source file in the assembly compilation.

Syntax

public System.IO.TextWriter CreateCodeFile (BuildProvider buildProvider)

Parameters

buildProvider
The build provider generating the code source file.

Returns

An open System.IO.TextWriter that can be used to write source code to a temporary file.

Remarks

A System.Web.Compilation.BuildProvider implementation calls the AssemblyBuilder.CreateCodeFile(BuildProvider) method when generating a source file for a virtual path. Source code added with AssemblyBuilder.CreateCodeFile(BuildProvider) is included in the assembly compilation.

Typically, a build provider BuildProvider.GenerateCode(AssemblyBuilder) method implementation reads the BuildProvider.VirtualPath property, parses the contents, and then adds the generated source code to the specified System.Web.Compilation.AssemblyBuilder object. The build provider uses the AssemblyBuilder.CreateCodeFile(BuildProvider) method to add source code as a physical file to the assembly. Alternately, the build provider can use the AssemblyBuilder.AddCodeCompileUnit(BuildProvider, System.CodeDom.CodeCompileUnit) method to add source code as a CodeDOM graph to the assembly.

After calling AssemblyBuilder.CreateCodeFile(BuildProvider), the build provider writes the source file contents using the returned System.IO.TextWriter object. After writing the source file, the System.Web.Compilation.BuildProvider object must use the System.IO.TextWriter.Close method to close the System.IO.TextWriter object and free associated system resources.

Requirements

Namespace: System.Web.Compilation
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0