visual studio installer制作安装包——Installer 类
链接:https://msdn.microsoft.com/zh-cn/library/system.configuration.install.installer.aspx
Installer 类
提供自定义安装的基础。
命名空间: System.Configuration.Install
程序集: System.Configuration.Install(System.Configuration.Install.dll 中)
System.MarshalByRefObject
System.ComponentModel.Component
System.Configuration.Install.Installer
System.Configuration.Install.AssemblyInstaller
System.Configuration.Install.ComponentInstaller
System.Configuration.Install.TransactedInstaller
System.Management.Instrumentation.DefaultManagementInstaller
System.Management.Instrumentation.DefaultManagementProjectInstaller
System.Management.Instrumentation.ManagementInstaller
| 名称 | 说明 | |
|---|---|---|
![]() |
Installer() |
初始化 Installer 类的新实例。 |
| 名称 | 说明 | |
|---|---|---|
![]() |
CanRaiseEvents |
获取一个指示组件是否可以引发事件的值。(从 Component 继承。) |
![]() |
Container |
获取 IContainer,它包含 Component。(从 Component 继承。) |
![]() |
Context |
获取或设置关于当前安装的信息。 |
![]() |
DesignMode | |
![]() |
Events | |
![]() |
HelpText |
获取安装程序集合中所有安装程序的帮助文字。 |
![]() |
Installers |
获取该安装程序包含的安装程序的集合。 |
![]() |
Parent |
获取或设置包含该安装程序所属的集合的安装程序。 |
![]() |
Site |
| 名称 | 说明 | |
|---|---|---|
![]() |
AfterInstall |
在 Installers 属性中的所有安装程序的 Install 方法都运行后发生。 |
![]() |
AfterRollback |
在回滚 Installers 属性中所有安装程序的安装后发生。 |
![]() |
AfterUninstall |
在 Installers 属性中所有安装程序都执行它们的卸载操作后发生。 |
![]() |
BeforeInstall |
在安装程序集合中每个安装程序的 Install 方法运行前发生。 |
![]() |
BeforeRollback |
在回滚 Installers 属性中的安装程序前发生。 |
![]() |
BeforeUninstall |
在 Installers 属性中的安装程序执行它们的卸载操作前发生。 |
![]() |
Committed |
在 Installers 属性中的所有安装程序均提交它们的安装后发生。 |
![]() |
Committing |
在 Installers 属性中的安装程序提交它们的安装前发生。 |
![]() |
Disposed |
这是.NET Framework 中的所有自定义安装程序类的基类。安装程序帮助的计算机上安装应用程序的组件。
有几个步骤必须遵循使用 Installer:
继承 Installer 类。
添加 RunInstallerAttribute 到派生类,并将其设置为 true。
将您的派生的类放在具有您的应用程序若要安装的程序集。
调用安装程序。例如,使用 InstallUtil.exe 来调用安装程序。
Installers 属性包含安装程序的集合。如果此实例的
Installer 是安装程序集合的一部分 Parent 属性设置为 Installer 包含列的集合的实例。为举例说明如何使用
Installers 集合,请参阅 AssemblyInstaller 类。
Install, ,Commit,
,Rollback, ,和
Uninstall 方法 Installer 类经历的安装程序中存储集合 Installers 属性,并调用每个安装程序的相应方法。
Install, ,Commit,
,Rollback, ,和
Uninstall 方法不会在同一个总是调用 Installer 实例。例如,一个
Installer 可能同时安装和提交应用程序中,使用实例,然后发布到该实例的引用。更高版本,卸载应用程序时将创建一个新的引用
Installer 实例,也就是说, Uninstall 方法由不同的实例调用 Installer。为此,在派生类中,不保存在一个安装程序中的计算机的状态。请改用
IDictionary ,它在调用之间保留并传递到您 Install, ,Commit, ,Rollback,
,和 Uninstall 方法。
两种情况下说明需要将信息保存在状态保护程序中 IDictionary。首先,假设您的安装程序设置一个注册表项。它应将保存的键中的原始值
IDictionary。如果安装被回滚,则可以还原原始值。其次,假定安装程序替换现有文件。将现有的文件保存在临时目录和文件中的新位置的位置中
IDictionary。如果安装被回滚,较新的文件被删除,并替换为从临时位置原始。
Installer.Context 属性包含有关安装的信息。例如,安装过程中,要保存所需的信息的文件的位置的日志文件的位置有关的信息
Uninstall 方法,并安装可执行文件运行时输入的命令行。
下面的示例演示如何使用 Installer 类。它将创建一个类,该类继承自
Installer。当
Commit 即将完成, Committing 事件发生并显示一条消息。若要使用
Installer 类中,您必须引用 System.Configuration.Install 您的项目中的程序集。
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install; // Set 'RunInstaller' attribute to true.
[RunInstaller(true)]
public class MyInstallerClass: Installer
{
public MyInstallerClass() :base()
{
// Attach the 'Committed' event.
this.Committed += new InstallEventHandler(MyInstaller_Committed);
// Attach the 'Committing' event.
this.Committing += new InstallEventHandler(MyInstaller_Committing); }
// Event handler for 'Committing' event.
private void MyInstaller_Committing(object sender, InstallEventArgs e)
{
Console.WriteLine("");
Console.WriteLine("Committing Event occured.");
Console.WriteLine("");
}
// Event handler for 'Committed' event.
private void MyInstaller_Committed(object sender, InstallEventArgs e)
{
Console.WriteLine("");
Console.WriteLine("Committed Event occured.");
Console.WriteLine("");
}
// Override the 'Install' method.
public override void Install(IDictionary savedState)
{
base.Install(savedState);
}
// Override the 'Commit' method.
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
}
// Override the 'Rollback' method.
public override void Rollback(IDictionary savedState)
{
base.Rollback(savedState);
}
public static void Main()
{
Console.WriteLine("Usage : installutil.exe Installer.exe ");
}
}
1.1 后可用
此类型的任何公共静态(Visual Basic 中为 Shared)成员都是线程安全的。但不保证所有实例成员都是线程安全的。
visual studio installer制作安装包——Installer 类的更多相关文章
- 使用Visual Studio发布应用安装包
安装包制作方式 使用Visual Studio进行应用的打包分发有两种方式: 1.使用Clickonce发布安装包: 2.使用Setup工程发布安装包. 操作步骤 Clickonce发布安装包 1.右 ...
- 创建Visual Studio 2019离线安装包
可以在不同的网络环境和不同的计算机上在线安装微软Visual Studio 2019.微软提供的在线安装工具(Visual Studio web installer)可以让用户在线下载最新版本Visu ...
- Visual Studio 2017离线安装包,百度云分流
Visual Studio正式版发布了,然而只能在线安装.虽然官方有提供了离线的方法,但还是蛮复杂的,所以我打包了两个版本发布至百度云分享. 离线分流 地址:http://pan.baidu.com/ ...
- Visual Studio 2017 离线安装包
vs_community.exe --layout D:vs2017offline-en --add Microsoft.VisualStudio.Workload.ManagedDesktop -- ...
- Visual Studio 2017离线安装包下载、安装
1. 首先下载在线安装exe,官网地址https://www.visualstudio.com/zh-hans/downloads/ 2. 运行CMD, 执行脚本 vs_enterprise.exe ...
- Visual Studio 6.0安装包
点击下载
- Visual Studio 2017离线安装包
点击下载
- [转载]如何用Visual Studio制作安装包
原文地址:如何用Visual Studio制作安装包作者:蓝羽幽游 环境:Microsoft Visual Studio 2010 语言:C# 构架:.NET Framework 2.0 解决方案名称 ...
- 使用Qt installer framework制作安装包
一.介绍 使用Qt库开发的应用程序,一般有两种发布方式:(1)静态编译发布.这种方式使得程序在编译的时候会将Qt核心库全部编译到一个可执行文件中.其优势是简单单一,所有的依赖库都集中在一起,其缺点也很 ...
随机推荐
- 无需输入密码的scp/ssh/rsync操作方法
一般使用scp/ssh/rsync传输文件时,都需要输入密码.下面是免密码传输文件的方法. 假设要在两台主机之间传送文件,host_src & host_dst.host_src是文件源地址所 ...
- ES6 - for...of
for...of是一种用来遍历数据结构的方法,可遍历的对象包括:数组,对象,字符串,节点数组等 我们先来看一下现在存在的遍历方式: var arr=[1,2,3,4] (1)for循环 缺点:代码不够 ...
- php:上传多个文件
<?php class upload { public $files; public $seterror; public $allowtype; public $file ...
- 关于 MAXScript 逐行写入文本
官方帮助文档FileStream Values部分有相关介绍. fn format_txt filepath filetext = ( if doesFileExist filepath == tru ...
- mac10.9+php5.5.15+brew0.9.5的安装
Brew 是 Mac 下面的包管理工具,通过 Github 托管适合 Mac 的编译配置以及 Patch,可以方便的安装开发工具. Mac 自带ruby 所以安装起来很方便,同时它也会自动把git ...
- The error occurred while setting parameters--索引 3 超出范围 sqlserver2008
这个问题不是jar包冲突,是表的问题,表里的ID设置成自动增加1,就可以了!
- Dictionary 序列化与反序列化
[转:http://blog.csdn.net/woaixiaozhe/article/details/7873582] 1.说明:Dictionary对象本身不支持序列化和反序列化,需要定义一个继承 ...
- jQuery使用load方法加载其他文档内容
A文档载入B文档的内容,并且通过JQ操作被引入到A文档中的元素 A文档 (index.html): <!DOCTYPE html> <html lang="en" ...
- 【uTenux实验】集合点端口
这个是头一次接触的概念.比较不好理解.内核规范中的说明就要20页! 看了王总写的uTenux内核规范之后,有那么一点明白了但理解不深. 集合点端口就像每次工作前的收集情况会.首长下达收集情况指令,各个 ...
- PLSQL转义字符
http://blog.csdn.net/cunxiyuan108/article/details/5800800




