[英]Cancelling Installer from Installing setup in Visual Studio Setup
I have a installer class which is taking a vale from the user at the time of installation.Now as per my requirement if the value provided is not correct i have to cancel the installation but i am not getting how to get this .. 我有一个安装程序类,它在安装时会引起用户的注意。现在根据我的要求,如果提供的值不正确,我必须取消安装,但我没有得到如何安装它的方法..
Here is my installer.cs file.. 这是我的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);
}
}
Inspite of Rollback(stateSaver);
尽管
Rollback(stateSaver);
my setup gets installed.. 我的安装程序已安装。
Please help me.. 请帮我..
Just calling InstallException will do the rollback. 仅调用InstallException即可进行回滚。 That's the usual way and it works, so if it doesn't then something else is going on.
这是通常的方式,并且可以正常工作,因此,如果没有,则说明正在进行其他操作。
You should think about using another tool that lets you validate the data when it gets entered. 您应该考虑使用另一个工具,该工具可让您在输入数据时验证数据。 VS custom actions always run after all the files have been installed, so basically you're installing the entire app and then rolling it back rather than using an MSI build tool that lets you validate when it's entered.
VS自定义操作始终在所有文件安装完毕后运行,因此,基本上,您是先安装整个应用程序,然后回滚它,而不是使用MSI构建工具验证输入时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.