【发布时间】:2014-05-15 10:17:33
【问题描述】:
我有一个安装程序类,它在安装时从用户那里获取价值。现在根据我的要求,如果提供的值不正确,我必须取消安装,但我不知道如何获得它。 .
这是我的 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); 我的设置已安装..
请帮帮我..
【问题讨论】:
-
我相信,抛出异常应该会导致
Rollback()被调用。你不应该自己称呼它。 -
@Damien_The_Unbeliever throw new InstallException("Your input is wrong""); 像这样我必须使用
标签: c# visual-studio-2010 installation setup-project