我有一个installer类,它根据我的要求在installation.Now时从用户那里获取一个值,如果提供的值不正确,我必须取消安装,但我不知道如何获得它。
这是我的installer.cs文件..
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
// Retrieve configuration settings
string targetSite = Context.Parameters["targetsite"];
string targetVDir = Context.Parameters["targetvdir"];
string targetDirectory = Context.Parameters["targetdir"];
string value = Context.Parameters["value"];
string connectionstring = Context.Parameters["db"];
if (targetSite == null)
throw new InstallException("IIS Site Name Not Specified!");
if (targetSite.StartsWith("/LM/"))
targetSite = targetSite.Substring(4);
if (connectionstring == null)
throw new InstallException("You did not specify a database to use!");
if (value.Equals("123"))
{
RegisterScriptMaps(targetSite, targetVDir);
ConfigureDatabase(targetSite, targetVDir, connectionstring);
}
else {
Rollback(stateSaver);
}
}
尽管安装了Rollback(stateSaver);
,我的安装程序还是安装了..
请帮帮我..
发布于 2014-05-15 22:17:22
只需调用InstallException即可执行回滚。这是通常的方式,它起作用了,所以如果它不起作用,那么一定是发生了其他事情。
您应该考虑使用另一个工具,让您在输入数据时对其进行验证。VS自定义操作总是在所有文件安装完成后运行,所以基本上你是在安装整个应用程序,然后回滚它,而不是使用MSI构建工具,让你在进入应用程序时进行验证。
https://stackoverflow.com/questions/23675391
复制相似问题