RegisterAssembly 类


为 COM 互操作注册一个托管程序集(等效于 regasm.exe 功能,但此代码实际上不会调用 exe)。Registers a managed assembly for COM interop (equivalent of regasm.exe functionality, but this code doesn't actually call the exe).

此 API 支持产品基础结构,不能在代码中直接使用。

public ref class RegisterAssembly : Microsoft::Build::Tasks::AppDomainIsolatedTaskExtension, System::Runtime::InteropServices::ITypeLibExporterNotifySink
public class RegisterAssembly : Microsoft.Build.Tasks.AppDomainIsolatedTaskExtension, System.Runtime.InteropServices.ITypeLibExporterNotifySink
type RegisterAssembly = class
    inherit AppDomainIsolatedTaskExtension
    interface ITypeLibExporterNotifySink
Public Class RegisterAssembly
Inherits AppDomainIsolatedTaskExtension
Implements ITypeLibExporterNotifySink


Framework64/ <version> /RegisterAssemblyTask 无法解析注册为32位组件的 COM 对象库。Framework64/<version>/RegisterAssemblyTask cannot resolve a library of COM objects registered as 32-bit components. Framework/ <version> /RegisterAssemblyTask 无法解析注册为64位组件的 COM 对象库。Framework/<version>/RegisterAssemblyTask cannot resolve a library of COM objects registered as 64-bit components.

例如,如果将名为 Classlibrary1.chainone 的 COM 对象库注册到64位计算机上的32位组件,请运行 Visual Studio,并将目标更改为 x64,生成将失败,并出现以下错误:For example, if you register a library of COM objects called ClassLibrary1 as 32-bit components on a 64-bit machine, run Visual Studio, and change the target to x64, the build fails with the following error:

ClassLibrary1.dll is not a valid assembly



此 API 支持产品基础结构,不能在代码中直接使用。

初始化 RegisterAssembly 类的新实例。Initializes a new instance of the RegisterAssembly class.



此 API 支持产品基础结构,不能在代码中直接使用。

获取或设置要向 COM 注册的程序集。Gets or sets the assemblies to be registered with COM.


此 API 支持产品基础结构,不能在代码中直接使用。

Register/UnregisterAssembly 的缓存文件。The cache file for Register/UnregisterAssembly. 需要 UnregisterAssembly 执行适当的清理。Necessary for UnregisterAssembly to do the proper clean up.


生成引擎自动设置此属性,以允许任务回调到其中。The build engine automatically sets this property to allow tasks to call back into it.

(继承自 AppDomainIsolatedTask)

此 API 支持产品基础结构,不能在代码中直接使用。

获取或设置一个布尔值,该值指定任务是否在注册表中创建 codebase 项,该项指定未在全局程序集缓存中安装的程序集的文件路径。Gets or sets a Boolean value that specifies whether the task creates a codebase entry in the registry, which specifies the file path for an assembly that is not installed in the global assembly cache.


获取或设置前缀,该前缀用于通过字符串资源名称组成 help 关键字。Gets or sets the prefix used to compose help keywords from string resource names. 如果任务没有与消息关联的 help 关键字,则可以忽略此属性或将其设置为 null。If a task does not have help keywords associated with its messages, it can ignore this property or set it to null. 如果前缀设置为空字符串,则字符串资源名称将逐字用作 help 关键字。If the prefix is set to an empty string, then string resource names will be used verbatim as help keywords. 有关如何使用此前缀的示例,请参见 LogErrorWithCodeFromResources(String, Object[]) 方法。For an example of how this prefix is used, see the LogErrorWithCodeFromResources(String, Object[]) method.

(继承自 AppDomainIsolatedTask)

如果主机 IDE 具有与此特定任务关联的主机对象,则生成引擎会设置此属性。The build engine sets this property if the host IDE has associated a host object with this particular task.

(继承自 AppDomainIsolatedTask)

此 API 支持产品基础结构,不能在代码中直接使用。

获取包含任务日志记录方法的 TaskLoggingHelperExtension 类的实例。Gets an instance of a TaskLoggingHelperExtension class containing task logging methods.

(继承自 AppDomainIsolatedTaskExtension)

获取或设置任务的区域性特定资源。Gets or sets the task's culture-specific resources. 派生类应在构造期间注册资源,如果它们有本地化字符串,则可以通过此属性注册。Derived classes should register their resources either during construction, or via this property, if they have localized strings.

(继承自 AppDomainIsolatedTask)

此 API 支持产品基础结构,不能在代码中直接使用。

获取或设置要从指定的程序集中生成的类型库。Gets or sets the type library to generate from the specified assembly.



创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(继承自 MarshalByRefObject)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)

此 API 支持产品基础结构,不能在代码中直接使用。

任务入口点Task entry point


作为默认哈希函数。Serves as the default hash function.

(继承自 Object)

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(继承自 MarshalByRefObject)

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

重写以赋予从这个类派生的任务无限的租约时间。Overridden to give tasks deriving from this class infinite lease time. 否则,我们最终会获得一个有限的租约(大约 5 分钟),如果任务实例处理时间较长,就会过期。Otherwise we end up with a limited lease (5 minutes I think) and task instances can expire if they take long time processing.

(继承自 AppDomainIsolatedTask)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(继承自 MarshalByRefObject)
ReportEvent(ExporterEventKind, Int32, String)

此 API 支持产品基础结构,不能在代码中直接使用。

用于报告类型库导出事件的回调方法Callback method for reporting type library export events


此 API 支持产品基础结构,不能在代码中直接使用。

用于查找给定程序集的类型库的回调方法。Callback method for finding type libraries for given assemblies. 如果出现这种情况,则表示我们要查找的类型库不在当前目录中,也不是已注册的类型库。If we are here, it means the type library we're looking for is not in the current directory and it's not registered. 目前假设已注册所有依赖类型库。Currently we assume that all dependent type libs are already registered.


返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)