繁体   English   中英

在具有 32 位应用程序的 64 位机器上从 c# 代码安装 IIS

[英]Installing IIS from c# code on 64bit machine with 32bit application

我正在尝试在 64 位机器上安装 IIS。 安装的是 32 位 c# 应用程序。

代码如下(取自 此处):

Process proc = new Process();
string cmd = @"C:\Windows\System32\pkgmgr.exe";
string cmdargument =
            @" start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;
            IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;
            IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;
            IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;
            IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;
            IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;
            WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3";

proc = Process.Start(cmd, cmdargument);
proc.WaitForExit();
proc.Close();

当应用程序编译为“AnyCPU”时,一切正常。 但它是用“x86”编译的,PkgMgr window 显示错误:“试图加载格式不正确的程序”。

我还尝试从 wow32 文件夹运行 PkgMgr,但效果不佳。

任何想法? 谢谢。

我想我找到了一个解决方案,它不是最佳的,但它有效。 我正在用 AnyCPU 编译包装 PkgMgr 执行并完成工作。

我仍然想找到一个更“正确”的解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM