使用Inno Installer安装SQL Server Express 2017失败求助
Let’s break down why your SQL Server install works in CMD but fails in Inno Installer, and how to fix it. That System.MissingMethodException typically points to a mismatch in the execution context (like permissions or working directory) between your CMD session and Inno’s runtime. Here are the most likely fixes:
1. Enforce Administrator Privileges
SQL Server requires elevated permissions to install, and Inno Installer doesn’t automatically run child processes with admin rights—even if the main installer is elevated.
First, add this to your [Setup] section to ensure the entire installer runs with admin privileges:
[Setup] PrivilegesRequired=admin
Then, update your [Run] entry to explicitly mark the SQL setup as needing admin access with the runasadmin flag.
2. Fix the Working Directory
When you run the command in CMD, you’re probably executing it directly from the SQLEXPR_x64_ENU folder, so setup can easily find all dependent files and your configuration file. In Inno, if you don’t specify a working directory, it defaults to the installer’s temp folder or system directory, which breaks relative path references.
Update your [Run] section to set the working directory to the extracted SQL setup folder, and use absolute paths for the configuration file:
[Run] Filename: "{tmp}\SQLEXPR_x64_ENU\setup.exe"; Parameters: "/ACTION=Install /Q /SKIPRULES=RebootRequiredCheck /SUPPRESSPRIVACYSTATEMENTNOTICE=1 /IAcceptSQLServerLicenseTerms=1 /SECURITYMODE=SQL /SAPWD=secretPW /ConfigurationFile={tmp}\SQLEXPR_x64_ENU\ConfigurationFileExpr.ini"; WorkingDir: "{tmp}\SQLEXPR_x64_ENU"; Flags: runasadmin waituntilterminated
The waituntilterminated flag ensures Inno waits for SQL setup to finish before proceeding, which avoids unexpected behavior.
3. Verify Full File Extraction
Double-check that your Inno [Files] section is extracting every file from the SQLEXPR_x64_ENU folder. Missing DLLs or setup components can trigger the MissingMethodException when setup tries to load required classes.
Use this entry to ensure complete extraction:
[Files] Source: "SQLEXPR_x64_ENU\*"; DestDir: "{tmp}\SQLEXPR_x64_ENU"; Flags: recursesubdirs createallsubdirs
4. Check Environment Variable Consistency
In rare cases, the environment variables available to Inno might differ from your CMD session. If SQL setup relies on specific PATH entries or system variables, you can set them explicitly in your script before running the setup using the SetEnv function.
Final Troubleshooting Step
If the issue persists, add verbose logging to your SQL setup parameters (append /INDICATEPROGRESS /VERBOSE) to get granular details about where the setup is failing. This will help pinpoint missing components or permission issues you might have missed.
内容的提问来源于stack exchange,提问作者Eager2Learn

