dotnet/runtime · error

Option : invalid form

Error message

Option %s: invalid form

What it means

Printed at src/coreclr/hosts/corerun/corerun.cpp:769 when an option token consists of only a single dash/flag character (arg length is 1). corerun cannot tell which option was intended, so it bails out of argument parsing.

Solutions

  1. Inspect the corerun command line and remove or correct the lone `-`.
  2. Use `corerun --help` to list valid options.
  3. Quote arguments in shell scripts to avoid a stray dash being passed.

Example fix

// before
corerun - HelloWorld.dll
// after
corerun -d HelloWorld.dll
Defensive patterns

Strategy: validation

Validate before calling

// Before calling corerun, scrub argv
bool clean_args(int argc, char** argv) {
    for (int i=1;i<argc;i++) {
        if (argv[i][0]=='-' && argv[i][1]=='\0') return false; // lone dash
    }
    return true;
}

Prevention

When it happens

Trigger: Triggered when argv[i] is exactly "-" (one character). parse_args sets is_option true because the first char is a dash, then finds arg_len==1 and prints this message before breaking out of the loop.

Common situations: A typo such as `corerun - assembly.dll` where the user meant `-d`, or shell pipelines that inadvertently pass a lone dash to corerun.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/78d02a04c1d83ec9. Report an issue: GitHub.

Appendix: source

Thrown at src/coreclr/hosts/corerun/corerun.cpp:769

            i++; // Move to next argument.

            config.entry_assembly_argc = argc - i;
            config.entry_assembly_argv = (const char_t**)::malloc(config.entry_assembly_argc * sizeof(const char_t*));
            assert(config.entry_assembly_argv != nullptr);
            for (int c = 0; c < config.entry_assembly_argc; ++c)
            {
                config.entry_assembly_argv[c] = pal::strdup(argv[i + c]);
            }

            // Successfully parsed arguments.
            return true;
        }

        const char_t* arg = argv[i];
        size_t arg_len = pal::strlen(arg);
        if (arg_len == 1)
        {
            pal::fprintf(stderr, W("Option %s: invalid form\n"), arg);
            break; // Invalid option
        }

        const char_t* option = arg + 1;
        if (option[0] == W('-')) // Handle double '--'
            option++;

        // Path to core_root
        if (pal::strcmp(option, W("c")) == 0 || (pal::strcmp(option, W("clr-path")) == 0))
        {
            i++;
            if (i < argc)
            {
                config.clr_path = argv[i];
            }
            else
            {
                pal::fprintf(stderr, W("Option %s: missing path\n"), arg);

View on GitHub (pinned to 60108ba66e)