Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.InvalidOperationException: Reflection-based serialization has been disabled for this application #537

Closed
scorpionfly7 opened this issue Mar 18, 2024 · 3 comments · Fixed by #538
Assignees
Labels
question Further information is requested

Comments

@scorpionfly7
Copy link

How to resolve this:
Unhandled Exception: System.InvalidOperationException: Reflection-based serialization has been disabled for this application. Either use the source generator APIs or explicitly configure the 'JsonSerializerOptions.TypeInfoResolver' property.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled() + 0x30
at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer() + 0x44
at Microsoft.Extensions.Configuration.AzureAppConfiguration.JsonKeyValueAdapter.ProcessKeyValue(ConfigurationSetting, Logger, CancellationToken) + 0xac
at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__38.MoveNext() + 0x138
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x90
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x68
at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__29.MoveNext() + 0x1b4
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x90
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x68
at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__32.MoveNext() + 0x4cc
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x90
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x68
at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__31.MoveNext() + 0xe0
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x90
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x68
at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__30.MoveNext() + 0x1b8
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x24
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0x90
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task, ConfigureAwaitOptions) + 0x68
at Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.Load() + 0x24c
at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(IConfigurationSource) + 0x44

@zhenlan zhenlan added the question Further information is requested label Mar 20, 2024
@amerjusupovic
Copy link
Member

Hi @scorpionfly7, based on the exception I was able to find this documentation about the issue. The provider uses reflection-based serialization for json values, so it seems like this issue is expected for native AOT apps. Do you know if it's enabled for your application? If not, could you tell me more about the type of application you have and the version of .NET it uses?

@scorpionfly7
Copy link
Author

scorpionfly7 commented Mar 20, 2024

@amerjusupovic We don’t want to enable this feature for whole app. We have .net core application, . Net 8, using last version of app configuration SDK. Is there way, which not requires turn on of that option?

@amerjusupovic
Copy link
Member

@scorpionfly7 Currently, using key-values with application/json in the content type won't work while reflection-based serialization is disabled. We do intend to allow native AOT apps to use all of the features of App Configuration though, so we're looking into a solution. Thank you for bringing up this issue.

@amerjusupovic amerjusupovic transferred this issue from Azure/AppConfiguration Mar 25, 2024
@amerjusupovic amerjusupovic linked a pull request Mar 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants