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

时间:2022-07-18 07:23:49

I'm trying to install IIS on a 64bit machine. The installation is a 32bit c# application.

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

The code is as follows (taken from here):

代码如下(取自此处):

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();

When the application is compiled to "AnyCPU" everything works fine. But it is compiled with "x86" the PkgMgr window shows an error: "An attempt was made to load a program with an incorrect format".

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

I also tried to run the PkgMgr from the wow32 folder but it didn't work as well.

我也尝试从wow32文件夹运行PkgMgr,但它也没有用。

Any idea? Thanks.

任何想法?谢谢。

1 个解决方案

#1


0  

I think I found a solution, it is not optimal but it works. I'm wrapping the PkgMgr execution with an AnyCPU compilation and does the work.

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

I still would like to find a more "right" solution.

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

#1


0  

I think I found a solution, it is not optimal but it works. I'm wrapping the PkgMgr execution with an AnyCPU compilation and does the work.

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

I still would like to find a more "right" solution.

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