{"record":{"id":"3927c638438e694b","repo":"abpframework/abp","slug":"an-error-occurred-during-preconfigureservices-phas","errorCode":null,"errorMessage":"An error occurred during PreConfigureServices phase of the module {module.Type.AssemblyQualifiedName}. See the inner exception for details.","messagePattern":"An error occurred during PreConfigureServices phase of the module (.+?)\\. See the inner exception for details\\.","errorType":"exception","errorClass":"AbpInitializationException","httpStatus":null,"severity":"critical","filePath":"framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs","lineNumber":335,"sourceCode":"\n        foreach (var module in Modules)\n        {\n            if (module.Instance is AbpModule abpModule)\n            {\n                abpModule.ServiceConfigurationContext = context;\n            }\n        }\n\n        //PreConfigureServices\n        foreach (var module in Modules.Where(m => m.Instance is IPreConfigureServices))\n        {\n            try\n            {\n                ((IPreConfigureServices)module.Instance).PreConfigureServices(context);\n            }\n            catch (Exception ex)\n            {\n                throw new AbpInitializationException($\"An error occurred during {nameof(IPreConfigureServices.PreConfigureServices)} phase of the module {module.Type.AssemblyQualifiedName}. See the inner exception for details.\", ex);\n            }\n        }\n\n        var assemblies = new HashSet<Assembly>();\n\n        //ConfigureServices\n        foreach (var module in Modules)\n        {\n            if (module.Instance is AbpModule abpModule)\n            {\n                if (!abpModule.SkipAutoServiceRegistration)\n                {\n                    foreach (var assembly in module.AllAssemblies)\n                    {\n                        if (!assemblies.Contains(assembly))\n                        {\n                            Services.AddAssembly(assembly);\n                            assemblies.Add(assembly);","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationBase.cs#L317-L353","documentation":"The synchronous counterpart of error 241. ABP iterates every module implementing IPreConfigureServices and calls PreConfigureServices(context) - the earliest sync lifecycle phase. If any module throws, ABP wraps it in AbpInitializationException naming the module's AssemblyQualifiedName with the original as InnerException. The real cause is always the inner exception.","triggerScenarios":"A module's PreConfigureServices override throws: bad config binding, null reference reading settings, or registering something that errors.","commonSituations":"Typo in an appsettings.json key read at pre-configure; ABP version mismatch; a connection string referenced in PreConfigureServices that is absent; environment-specific config not loaded.","solutions":["Inspect ex.InnerException and its stack trace - the true exception and source line live there.","Open the PreConfigureServices override of the module named in the message.","Verify the configuration section or connection string the module reads at pre-configure time is present and well-formed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    application.ConfigureServices();\n}\ncatch (AbpInitializationException ex) when (ex.Message.Contains(\"PreConfigureServices\"))\n{\n    startupLogger.LogError(ex.InnerException, \"PreConfigure failed in {Module}\", ex.Message);\n    throw;\n}","preventionTips":["Log and read ex.InnerException - the wrapper hides the real cause.","Unit-test each module's PreConfigureServices with the real IConfiguration.","Pre-validate required config sections before startup."],"tags":["module-system","initialization","preconfigure","sync"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}