{"record":{"id":"4b1021865d8ebf02","repo":"dotnet/runtime","slug":"error-invalid-option-s","errorCode":null,"errorMessage":"Error : Invalid Option: %s\n","messagePattern":"Error : Invalid Option: (.+?)\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/coreclr/ilasm/main.cpp","lineNumber":530,"sourceCode":"                        if(pStr == NULL) goto InvalidOption;\n                        pStr++;\n                        const CHAR *pFmt = ((*pStr=='0')&&(*(pStr+1) == 'x'))? \"%x\" : \"%d\";\n                        NarrowForNumberParsing str{pStr};\n                        if(sscanf_s(str,pFmt,&g_dwTestRepeat)!=1) goto InvalidOption;\n                    }\n#endif\n                    else if (!_stricmp(szOpt, \"ANA\"))\n                    {\n                        WCHAR *pEqualOrColon = EqualOrColon(argv[i]);\n                        if (pEqualOrColon == NULL) goto InvalidOption;\n                        MAKE_UTF8PTR_FROMWIDE_NOTHROW(anameOverride, pEqualOrColon + 1);\n                        pAsm->m_pOverrideAssemblyName = _strdup(anameOverride);\n                    }\n                    else\n                    {\n                    InvalidOption:\n                        MAKE_UTF8PTR_FROMWIDE_NOTHROW(invalidOpt, argv[i]);\n                        fprintf(stderr, \"Error : Invalid Option: %s\\n\", invalidOpt);\n                        goto ErrorExit;\n                    }\n                }\n                else\n                {\n                    if(u16_strlen(argv[i]) >= MAX_FILENAME_LENGTH)\n                    {\n                        printf(\"\\nError: Input file name exceeds %d characters\\n\",MAX_FILENAME_LENGTH-1);\n                        goto ErrorExit;\n                    }\n                    pwzInputFiles[NumFiles++] = argv[i];\n                    if(NumFiles == 1)\n                    {\n                        MakeProperSourceFileName(argv[i], uCodePage, wzInputFilename, szInputFilename);\n                    }\n                }\n\n            }","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/ilasm/main.cpp#L512-L548","documentation":"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.","triggerScenarios":"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.","commonSituations":"Wrong tool in mind (passing csc/cl flags to ilasm); shell-quoting accident producing a stray token; version differences in supported switches.","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."],"exampleFix":"// before\nilasm /target:library foo.il\n// after\nilasm /DLL foo.il","handlingStrategy":"validation","validationCode":"// Whitelist known ilasm switches before assembling the command line.\nconst 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']);\nfor (const opt of argv) if (opt.startsWith('/') && !KNOWN.has(opt.slice(1).split(/[=:]/)[0].toUpperCase())) throw new Error('Unknown ilasm option: ' + opt);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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 -."],"tags":["ilasm","cli","invalid-option","usage"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}