Search code examples
c#exceptionparametersformatexception

System.FormatException: 'The short switch is not defined in the switch mappings.'


At this point of my OnStartup method… :

_host = Host.CreateDefaultBuilder(e.Args).ConfigureAppConfiguration(c => { c.SetBasePath(appLocation); })
            .ConfigureServices(ConfigureServices).Build();

… I get this exception:

1

But I don't use short switches and the -l=de is just a parameter which is defined in the launch profile. Does anyone know why this exception occurred and how to solve it?


Solution

  • Regarding .net documentation, it only supports 3 styles of arguments:

    1. key=value
    2. /key value (or /key=value)
    3. --key value (or --key=value)

    Your argument -l=de (-key=value) is not supported.

    https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-7.0#command-line-arguments