AssemblyBuilder.CreateCodeFile Method

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

Namespace: System.Web.Compilation
Assembly: System.Web (in system.web.dll)

public:
TextWriter^ CreateCodeFile (
	BuildProvider^ buildProvider
)
public TextWriter CreateCodeFile (
	BuildProvider buildProvider
)
public function CreateCodeFile (
	buildProvider : BuildProvider
) : TextWriter
Not applicable.

Parameters

buildProvider

The build provider generating the code source file.

Return Value

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

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

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

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

The following code example illustrates a simple build provider implementation, inheriting from the abstract BuildProvider base class. The build provider overrides the CodeCompilerType, GetGeneratedType, and GenerateCode members of the base class.

In the GenerateCode method implementation, the build provider adds the generated code for the assembly compilation using the CreateCodeFile method.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: