dotnet/runtime · error
Error : Invalid Option: %s
Error message
Error : Invalid Option: %s
What it means
ilasm fell through to the `InvalidOption` label (main.cpp:528-531): the switch prefix (`/` or `-`) was recognized but the option name or its argument did not match any known option, or a value-bearing option had no value. The offending argv element is printed so the user can see exactly which token was rejected.
Source
Thrown at src/coreclr/ilasm/main.cpp:530
if(pStr == NULL) goto InvalidOption;
pStr++;
const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? "%x" : "%d";
NarrowForNumberParsing str{pStr};
if(sscanf_s(str,pFmt,&g_dwTestRepeat)!=1) goto InvalidOption;
}
#endif
else if (!_stricmp(szOpt, "ANA"))
{
WCHAR *pEqualOrColon = EqualOrColon(argv[i]);
if (pEqualOrColon == NULL) goto InvalidOption;
MAKE_UTF8PTR_FROMWIDE_NOTHROW(anameOverride, pEqualOrColon + 1);
pAsm->m_pOverrideAssemblyName = _strdup(anameOverride);
}
else
{
InvalidOption:
MAKE_UTF8PTR_FROMWIDE_NOTHROW(invalidOpt, argv[i]);
fprintf(stderr, "Error : Invalid Option: %s\n", invalidOpt);
goto ErrorExit;
}
}
else
{
if(u16_strlen(argv[i]) >= MAX_FILENAME_LENGTH)
{
printf("\nError: Input file name exceeds %d characters\n",MAX_FILENAME_LENGTH-1);
goto ErrorExit;
}
pwzInputFiles[NumFiles++] = argv[i];
if(NumFiles == 1)
{
MakeProperSourceFileName(argv[i], uCodePage, wzInputFilename, szInputFilename);
}
}
}View on GitHub (pinned to 290d5ab72c)
Solutions
- Run `ilasm /?` to list supported options and correct the flagged token.
- Quote paths beginning with `/` or `-` and provide the missing `=` argument.
- Ensure you are invoking ilasm (IL Assembler) and not another tool.
Example fix
// before ilasm /target:library foo.il // after ilasm /DLL foo.il
Defensive patterns
Strategy: validation
Validate before calling
// Whitelist known ilasm switches before assembling the command line.
const KNOWN = new Set(['DLL','EXE','OUT','DEBUG','OPT','CLOCK','DETERMINISTIC','QUIET','NOLOGO','X86','X64','ARM64','32BITPREFERRED','ALI','BAS','FLA','SUB','SSV','MSV','MDV','INC','KEY','KEYSOURCE','ANC','ANA']);
for (const opt of argv) if (opt.startsWith('/') && !KNOWN.has(opt.slice(1).split(/[=:]/)[0].toUpperCase())) throw new Error('Unknown ilasm option: ' + opt); Prevention
- Run `ilasm /?` first to enumerate valid switches.
- Do not reuse flags from csc/cl; ilasm has its own set.
- Shell-quote anything that legitimately starts with / or -.
When it happens
Trigger: Typing an unrecognized flag (e.g. `/FOO`); a recognized flag missing its `=` value; a non-option token starting with `/` or `-` being parsed as a switch.
Common situations: Wrong tool in mind (passing csc/cl flags to ilasm); shell-quoting accident producing a stray token; version differences in supported switches.
Related errors
- Option %s: invalid form
- Error: Output file name exceeds %d characters
- File Alignment must be power of 2 from 0x200 to 0x10000
- Base address must be 0x10000-aligned
- Invalid Image Base specified for 32-bit target
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/4b1021865d8ebf02.
Report an issue: GitHub.