{"record":{"id":"502d0563524d837b","repo":"microsoft/autogen","slug":"configuration-not-found-configfile","errorCode":null,"errorMessage":"Configuration not found: {configFile}","messagePattern":"Configuration not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs","lineNumber":71,"sourceCode":"        }\n        catch (InvalidDataException ide)\n        {\n            Console.Error.WriteLine(\n                \"Unable to load semantic kernel settings, please provide configuration settings using instructions in the README.\\n\" +\n                \"Please refer to: https://github.com/microsoft/semantic-kernel-starters/blob/main/sk-csharp-hello-world/README.md#configuring-the-starter\"\n            );\n            throw new InvalidOperationException(ide.Message);\n        }\n    }\n\n    /// <summary>\n    /// Load the kernel settings from the specified configuration file if it exists.\n    /// </summary>\n    internal static KernelSettings FromFile(string configFile = DefaultConfigFile)\n    {\n        if (!File.Exists(configFile))\n        {\n            throw new FileNotFoundException($\"Configuration not found: {configFile}\");\n        }\n\n        var configuration = new ConfigurationBuilder()\n            .SetBasePath(Directory.GetCurrentDirectory())\n            .AddJsonFile(configFile, optional: true, reloadOnChange: true)\n            .AddEnvironmentVariables()\n            .Build();\n\n        return configuration.Get<KernelSettings>()\n               ?? throw new InvalidDataException($\"Invalid semantic kernel settings in '{configFile}', please provide configuration settings using instructions in the README.\");\n    }\n\n    /// <summary>\n    /// Load the kernel settings from user secrets.\n    /// </summary>\n    internal static KernelSettings FromUserSecrets()\n    {\n        var configuration = new ConfigurationBuilder()","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/samples/dev-team/seed-memory/config/KernelSettings.cs#L53-L89","documentation":"KernelSettings.FromFile throws FileNotFoundException when the specified settings JSON (default appsettings.json / config file) does not exist on disk at the given path. The seed-memory tool loads its Azure/OpenAI kernel configuration from this file, and the error is the first of three escalating guards (file missing -> file invalid -> user secrets invalid).","triggerScenarios":"Calling KernelSettings.FromFile(\"appsettings.json\"), or any custom configFile path, when the file is absent; running seed-memory from a directory other than the project output directory where the JSON was not copied.","commonSituations":"Fresh clone without creating the config file per the dev-team README; file exists in the repo root but the exe runs from bin/Debug without CopyToOutputDirectory; passing a relative path while Directory.GetCurrentDirectory() differs from the expected folder.","solutions":["Create the settings JSON at the expected path using the README template (embedding endpoint, key, deployment names).","Set the file to copy to output in the csproj: <None Update=\"appsettings.json\" CopyToOutputDirectory=\"PreserveNewest\" />.","Pass an absolute path to FromFile, or make the path relative to AppContext.BaseDirectory rather than the current directory.","Alternatively skip the file entirely and use user secrets: KernelSettings.FromUserSecrets()."],"exampleFix":"// before\ninternal static KernelSettings FromFile(string configFile = DefaultConfigFile)\n{\n    if (!File.Exists(configFile)) { throw new FileNotFoundException($\"Configuration not found: {configFile}\"); }\n\n// after (resolve relative to the app binary, not the CWD)\nvar resolved = Path.IsPathRooted(configFile) ? configFile : Path.Combine(AppContext.BaseDirectory, configFile);\nif (!File.Exists(resolved)) { throw new FileNotFoundException($\"Configuration not found: {resolved}\"); }","handlingStrategy":"validation","validationCode":"var resolved = Path.IsPathRooted(configFile) ? configFile : Path.Combine(AppContext.BaseDirectory, configFile);\nif (!File.Exists(resolved))\n{\n    Console.Error.WriteLine($\"Config file not found at {resolved}. Copy the README template and fill in your Azure OpenAI settings.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { settings = KernelSettings.FromFile(configFile); } catch (FileNotFoundException) { settings = KernelSettings.FromUserSecrets(); } // fall back to user secrets when the file is absent","preventionTips":["Resolve config paths against AppContext.BaseDirectory, not Directory.GetCurrentDirectory(), so bin/output and root launches both work.","Set config JSON files to CopyToOutputDirectory=PreserveNewest in the csproj.","Commit a config template (appsettings.template.json) so the required keys are discoverable without reading code."],"tags":["configuration","file-not-found","seed-memory","dev-team-sample","appsettings"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}