Component 类

提供 IComponent 接口的基实现并启用应用程序之间的对象共享。

**命名空间:**System.ComponentModel
**程序集:**System(在 system.dll 中)

语法

声明
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class Component
    Inherits MarshalByRefObject
    Implements IComponent, IDisposable
用法
Dim instance As Component
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class Component : MarshalByRefObject, IComponent, IDisposable
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class Component : public MarshalByRefObject, IComponent, IDisposable
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class Component extends MarshalByRefObject implements IComponent, IDisposable
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class Component extends MarshalByRefObject implements IComponent, IDisposable

备注

Component 是公共语言运行库中按引用封送的所有组件的基类。Component 可以进行远程处理,并且派生自 MarshalByRefObject 类。Component 提供 IComponent 接口的实现。MarshalByValueComponent 提供按值封送的 IComponent 的实现。

可以在任何实现 IContainer 接口的对象中承载 Component,并且可以从其容器中查询和获取服务。容器会为它所包含的每个 Component 创建一个 ISite。容器使用该站点来管理 Component,而 Component 则使用该站点与它的容器进行通信。

Component 应通过调用其 Dispose 方法来显式释放资源,而不通过隐式调用 Finalize 方法来等待自动内存管理。当释放一个 Container 时,同时会释放该 Container 中的所有组件。

继承层次结构

System.Object
   System.MarshalByRefObject
    System.ComponentModel.Component
       派生类

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Component 成员
System.ComponentModel 命名空间
IComponent
IContainer
Container
ISite