We get this Exception on production when seed OpenIdDict started couldn't execute this function (Abp function) FindByClientIdAsync(String clientId, CancellationToken cancellationToken)
[06:51:09 FTL] Host terminated unexpectedly!
Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module NanoPBMNeo.NanoPBMNeoHttpApiHostModule, NanoPBMNeo.HttpApi.Host, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: One or more errors occurred. (JsonObjectCreationHandling.Populate is incompatible with reference handling.). See the inner exception for details.
---> System.AggregateException: One or more errors occurred. (JsonObjectCreationHandling.Populate is incompatible with reference handling.)
---> System.InvalidOperationException: JsonObjectCreationHandling.Populate is incompatible with reference handling.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ObjectCreationHandlingPropertyCannotAllowReferenceHandling()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo.DetermineEffectiveObjectCreationHandlingForProperty()
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo.Configure()
at System.Text.Json.Serialization.Metadata.JsonTypeInfo.ConfigureProperties()
at System.Text.Json.Serialization.Metadata.JsonTypeInfo.Configure()
at System.Text.Json.Serialization.Metadata.JsonTypeInfo.<EnsureConfigured>g__ConfigureSynchronized|172_0()
at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type type, Boolean ensureConfigured, Nullable1 ensureNotNull, Boolean resolveIfMutable, Boolean fallBackToNearestAncestorType) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo.Configure() at System.Text.Json.Serialization.Metadata.JsonTypeInfo.ConfigureProperties() at System.Text.Json.Serialization.Metadata.JsonTypeInfo.Configure() at System.Text.Json.Serialization.Metadata.JsonTypeInfo.<EnsureConfigured>g__ConfigureSynchronized|172_0() at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type type, Boolean ensureConfigured, Nullable
1 ensureNotNull, Boolean resolveIfMutable, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializerOptions.GetTypeInfoForRootType(Type type, Boolean fallBackToNearestAncestorType)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at Volo.Abp.Json.SystemTextJson.AbpSystemTextJsonSerializer.Deserialize(Type type, String jsonString, Boolean camelCase)
at Volo.Abp.Caching.Utf8JsonDistributedCacheSerializer.Deserialize[T](Byte[] bytes)
at Volo.Abp.Caching.DistributedCache2.GetAsync(TCacheKey key, Nullable
1 hideErrors, Boolean considerUow, CancellationToken token)
at Volo.Abp.Caching.DistributedCache2.GetOrAddAsync(TCacheKey key, Func
1 factory, Func1 optionsFactory, Nullable
1 hideErrors, Boolean considerUow, CancellationToken token)
at Volo.Abp.OpenIddict.Applications.AbpOpenIddictApplicationCache.FindByClientIdAsync(String clientId, CancellationToken cancellationToken)
at OpenIddict.Core.OpenIddictApplicationManager1.FindByClientIdAsync(String identifier, CancellationToken cancellationToken) at OpenIddict.Core.OpenIddictApplicationManager
1.OpenIddict.Abstractions.IOpenIddictApplicationManager.FindByClientIdAsync(String identifier, CancellationToken cancellationToken)
at Nano_NanoPBMNeo.OpenIddict.OpenIddictDataSeedContributor.CreateApplicationAsync(String name, String type, String consentType, String displayName, String secret, List1 grantTypes, List
1 scopes, String redirectUri, String postLogoutRedirectUri, List1 permissions, String clientUri, String logoUri) in /app/src/NanoPBMNeo.Domain/OpenIddict/OpenIddictDataSeedContributor.cs:line 210 at Nano_NanoPBMNeo.OpenIddict.OpenIddictDataSeedContributor.CreateApplicationsAsync() in /app/src/NanoPBMNeo.Domain/OpenIddict/OpenIddictDataSeedContributor.cs:line 89 at Nano_NanoPBMNeo.OpenIddict.OpenIddictDataSeedContributor.SeedAsync(DataSeedContext context) in /app/src/NanoPBMNeo.Domain/OpenIddict/OpenIddictDataSeedContributor.cs:line 48 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at NanoPBMNeo.Data.Seeders.SeederService.Seed() in /app/src/NanoPBMNeo.Domain/Data/Seeders/Services/SeederService.cs:line 96 at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter
1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at NanoPBMNeo.NanoPBMNeoHttpApiHostModule.OnApplicationInitialization(ApplicationInitializationContext context) in /app/src/NanoPBMNeo.HttpApi.Host/NanoPBMNeoHttpApiHostModule.cs:line 360
at Volo.Abp.Modularity.AbpModule.OnApplicationInitializationAsync(ApplicationInitializationContext context)
at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.InitializeAsync(ApplicationInitializationContext context, IAbpModule module)
at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context)
--- End of inner exception stack trace ---
at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context)
at Volo.Abp.AbpApplicationBase.InitializeModulesAsync()
at Volo.Abp.AbpApplicationWithExternalServiceProvider.InitializeAsync(IServiceProvider serviceProvider)
at Microsoft.AspNetCore.Builder.AbpApplicationBuilderExtensions.InitializeApplicationAsync(IApplicationBuilder app)
1 Answer(s)
-
0
- The error
JsonObjectCreationHandling.Populate is incompatible with reference handling
occurs when System.Text.Json serialization options are misconfigured, often due to incompatible settings between ABP's distributed cache and the .NET JSON serializer. This typically happens after upgrading .NET or ABP versions, or when using distributed cache (e.g., Redis) with cached objects that have reference loops or require special handling.
To resolve this in ABP 9.x:
Check Distributed Cache Configuration
- Ensure your distributed cache (e.g., Redis) is configured correctly and does not use custom or legacy serialization settings that conflict with .NET 8/9 defaults.
- If you have custom
JsonSerializerOptions
, remove or update them to avoid setting bothReferenceHandler
andJsonObjectCreationHandling.Populate
.
Clear Existing Cache
- If the cache contains data serialized with incompatible settings from a previous version, clear your distributed cache (e.g., flush Redis). Old cache entries can cause deserialization failures after upgrades.
Update ABP and .NET Packages
- Make sure you are using compatible versions of ABP and .NET. If you are on .NET 8 or 9, use the latest ABP 9.x version and ensure all related NuGet packages are updated.
Review Custom Serialization Code
- If you have custom cache serializers or use
AbpSystemTextJsonSerializer
, ensure you do not set bothReferenceHandler
andJsonObjectCreationHandling.Populate
in yourJsonSerializerOptions
.
- If you have custom cache serializers or use
Example: Correct Cache Serializer Configuration
Configure<AbpSystemTextJsonSerializerOptions>(options => { options.JsonSerializerOptions.ReferenceHandler = null; // or ReferenceHandler.Preserve if needed, but not with Populate // Do not set JsonObjectCreationHandling.Populate });
- Restart Application
- After clearing the cache and updating configuration, restart your application.
For more details, see:
- ABP Caching Fundamentals
- ABP Redis Cache Integration
- Fixing OpenIddict Certificate Issues in IIS or Azure
If the problem persists, ensure all microservices or app instances use the same ABP and .NET versions and cache configuration.
Sources:
- https://abp.io/docs/latest/framework/fundamentals/caching
- https://abp.io/docs/latest/framework/fundamentals/redis-cache
- https://abp.io/community/articles/0znavo8r
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.
- The error