dotnet/runtime · error

Unknown option

Error message

Unknown option %s

What it means

Printed at src/coreclr/hosts/corerun/corerun.cpp:857 when an option token does not match any known option (c, p, l, d, st, e, ?, h, help) after stripping leading dashes. It is the fallback else-branch of the option switch.

Solutions

  1. Run `corerun --help` to list supported options.
  2. Remove the unsupported flag or replace it with the equivalent supported option.
  3. Upgrade corerun if the flag is documented for a newer version.

Example fix

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

Strategy: validation

Validate before calling

// Validate against the known option set
#include <set>
#include <string>
bool options_known(int argc, char** argv) {
    static const std::set<std::string> known = {"-c","--clr-path","-p","--property","-l","--preload","-d","--debug","-st","-e","--env","-?","-h","--help"};
    for (int i=1;i<argc;i++) {
        if (argv[i][0]=='-' && known.find(argv[i])==known.end()) return false;
    }
    return true;
}

Prevention

When it happens

Trigger: Triggered when a token starting with '-' or '--' is not one of the recognized options. E.g. `corerun --verbose MyApp.dll` or `corerun -X`.

Common situations: Misspelled option, using flags that belong to a different host (dotnet run vs corerun), or passing an option supported only in newer corerun builds.

Related errors


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

Appendix: source

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

        {
            i++;
            if (i >= argc)
            {
                pal::fprintf(stderr, W("Option %s: missing .env file path\n"), arg);
                break;
            }

            std::ifstream dotenvFile{ pal::convert_to_utf8(argv[i]) };
            config.dotenv_configuration = dotenv{ pal::string_t{ argv[i] }, dotenvFile};
        }
        else if ((pal::strcmp(option, W("?")) == 0 || (pal::strcmp(option, W("h")) == 0 || (pal::strcmp(option, W("help")) == 0))))
        {
            display_usage();
            break;
        }
        else
        {
            pal::fprintf(stderr, W("Unknown option %s\n"), arg);
            break;
        }
    }

    return false;
}

// Forward declaration for self testing method.
static int self_test();

//
// Entry points
//

int MAIN(const int argc, const char_t* argv[])
{
    configuration config{};
    if (!parse_args(argc, argv, config))

View on GitHub (pinned to 60108ba66e)