System.Reflection.Emit.ModuleBuilder.DefineResource Method

Defines the named managed embedded resource to be stored in this module.

Syntax

public System.Resources.IResourceWriter DefineResource (string name, string description)

Parameters

name
The name of the resource. name cannot contain embedded nulls.
description
The description of the resource.

Returns

A resource writer for the defined resource.

Remarks

The caller must not call the ResourceWriter.Generate() and ResourceWriter.Close() methods, because these methods are called by ModuleBuilder.Save when the dynamic assembly is written to disk.

Use this method to embed a managed resource. To embed a manifest resource blob, use the ModuleBuilder.DefineManifestResource(string, System.IO.Stream, System.Reflection.ResourceAttributes) method. For a summary of embedding and linking managed resources and manifest resource blobs, see the ModuleBuilder.DefineManifestResource(string, System.IO.Stream, System.Reflection.ResourceAttributes) method.

Note:

Starting with the net_v20sp1_long, this member no longer requires System.Security.Permissions.ReflectionPermission with the System.Security.Permissions.ReflectionPermissionFlag.ReflectionEmit flag. (See Security Issues in Reflection Emit.) To use this functionality, your application should target the net_v35_long or later.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0