ServiceInstaller.CopyFromComponent(IComponent) 方法
定义
将来自 ServiceBase 的一个实例的属性复制到此安装程序。Copies properties from an instance of ServiceBase to this installer.
public:
override void CopyFromComponent(System::ComponentModel::IComponent ^ component);
public override void CopyFromComponent (System.ComponentModel.IComponent component);
override this.CopyFromComponent : System.ComponentModel.IComponent -> unit
Public Overrides Sub CopyFromComponent (component As IComponent)
参数
- component
- IComponent
要从中进行复制的 IComponent。The IComponent from which to copy.
例外
正与该安装程序关联的组件并非从 ServiceBase 继承。The component you are associating with this installer does not inherit from ServiceBase.
注解
在代码中很少会调用此方法。This method will rarely be called within your code. CopyFromComponent通常由设计器调用。CopyFromComponent is usually called only by designers.
CopyFromComponent将参数的服务名称保存 component 到实例的 ServiceName ServiceInstaller 。CopyFromComponent saves the service name of the component parameter to the ServiceName of the ServiceInstaller instance. (因为参数必须是派生自的类的实例 ServiceBase ,所以 component 保证具有 ServiceBase.ServiceName 属性。 ) (Because the parameter must be an instance of a class that derives from ServiceBase, component is guaranteed to have a ServiceBase.ServiceName property.)
备注
如果你使用的是 Visual Studio 设计器,则当用户单击将 Add Installer 此类指定为其安装程序的组件时,将在设计时调用此方法。If you are using the Visual Studio designer, this method is called at design time when the user clicks Add Installer on a component that specified this class as its installer. 安装程序将从实时组件获取所有信息,并将其存储在安装时使用。The installer takes all information it can from the live component and stores it for use at install time.