我已经使用Visual Studio 2017 15.7.1版创建了一个安装项目。
我有此安装后的自定义操作:
[RunInstaller(true)]
public partial class PostInstallActions : Installer
{
private const string siteName = "Default Web Site";
private const string appPoolName = "TRZF AppPool";
private const string webAppPath = "/TRZF";
private const string windowsAuthenticationPath =
"system.webServer/security/authentication/windowsAuthentication";
public PostInstallActions()
{
InitializeComponent();
}
public override void Install(IDictionary state)
{
base.Install(state);
// Do my custom install actions
}
public override void Commit(IDictionary state)
{
base.Commit(state);
// Do my custom commit actions
ServerManager serverManager = new ServerManager();
ApplicationPool trzfAppPool =
serverManager.ApplicationPools.Add(appPoolName);
trzfAppPool.Enable32BitAppOnWin64 = true;
trzfAppPool.ManagedRuntimeVersion = "v4.0";
trzfAppPool.ProcessModel.IdentityType =
ProcessModelIdentityType.ApplicationPoolIdentity;
Application trzfApp = serverManager.Sites[siteName].Applications[webAppPath];
trzfApp.ApplicationPoolName = appPoolName;
Configuration config = trzfApp.GetWebConfiguration();
ConfigurationSection windowsAuthenticationSection =
config.GetSection(windowsAuthenticationPath);
windowsAuthenticationSection["enabled"] = true;
serverManager.CommitChanges();
}
}
在Windows 10 Enterprise 2016 LTSB 1607版上运行安装程序时出现错误。
错误处于“提交”阶段:
错误1001。错误1001。在Commit阶段发生异常 安装。此异常将被忽略并安装 将继续。但是,该应用程序可能无法正常运行 安装完成后。 ->此配置部分不能 在此路径上使用。当该部分锁定在 父级。锁定默认为 (overrideModeDefault =“ Deny”),或由带有 OverrideMode =“ Deny”或旧版allowOverride =“ false”。
我已经以管理权限运行了它,但是遇到了同样的错误。
如何解决此错误?
答案 0 :(得分:2)
Windows身份验证部分默认情况下处于锁定状态,因此您无法在web.config
中进行设置(您在上面的代码中尝试过此操作)。尝试在applicationHost.config
中将其设置为location
标签,如下所示
// server config "Website1"
var config = server.GetApplicationHostConfiguration();
// enable Windows authentication
var windowsSection = config.GetSection("system.webServer/security/authentication/windowsAuthentication", "WebSite1");
Assert.Equal(OverrideMode.Inherit, windowsSection.OverrideMode);
Assert.Equal(OverrideMode.Deny, windowsSection.OverrideModeEffective);
Assert.False(windowsSection.IsLocked);
Assert.True(windowsSection.IsLocallyStored);
var windowsEnabled = (bool)windowsSection["enabled"];
Assert.True(windowsEnabled);
windowsSection["enabled"] = false;
Assert.Equal(false, windowsSection["enabled"]);