You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading the Microsoft.Extensions.Hosting nuget from 8.0.1 to 9.0.0, I get the following error when running the executable compiled via AOT using source generation:
Unhandled Exception: System.MissingMethodException: Method not found: 'Void System.Text.Json.Serialization.Metadata.JsonObjectInfoValues1.set_ConstructorAttributeProviderFactory(System.Func1<System.Reflection.ICustomAttributeProvider>)'
The error does not happen with the previous versions, nor does it happen when compiled to a non-AOT executable using the latest version.
Reproduction Steps
Create the following minimalistic example project to test.
Then run the following commands, assuming you are on Windows:
dotnet publish -r win-x64 -c Release --property:PublishDir=./bin/Publish
cd bin\Publish
BugExample.exe
Expected behavior
The output should look like it does when using version 8.0.1:
EXPECTED OUTPUT
Hello, World!
Result: {"Foobar":"Test"}
Actual behavior
Serialization fails with method not found:
ACTUAL OUTPUT
Hello, World!
Unhandled Exception: System.MissingMethodException: Method not found: 'Void System.Text.Json.Serialization.Metadata.JsonObjectInfoValues`1<Example>.set_ConstructorAttributeProviderFactory(System.Func`1<System.Reflection.ICustomAttributeProvider>)'.
at Internal.Runtime.TypeLoaderExceptionHelper.CreateMissingMethodException(ExceptionStringID, String) + 0x40
at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowMissingMethodException(ExceptionStringID, String) + 0x9
at SourceGenerationContext.Create_Example(JsonSerializerOptions) + 0x15
at System.Text.Json.JsonSerializerOptions.GetTypeInfoNoCaching(Type) + 0x39
at System.Text.Json.JsonSerializerOptions.CachingContext.CreateCacheEntry(Type type, JsonSerializerOptions.CachingContext context) + 0x1d
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
at System.Text.Json.JsonSerializerOptions.CachingContext.CacheEntry.GetResult() + 0x1e
at System.Text.Json.JsonSerializerOptions.GetTypeInfoInternal(Type, Boolean, Nullable`1, Boolean, Boolean) + 0x3c at System.Text.Json.JsonSerializerOptions.GetTypeInfo(Type) + 0x4c at SourceGenerationContext.get_Example() + 0x36 at Program.<Main>$(String[] args) + 0x4b at BugExample!<BaseAddress>+0x153960
Regression?
The closest issue I could find from the past that was somewhat related to this was #61737. Seems to be something now that has changed with JsonObjectInfoValues in the latest version.
Known Workarounds
Use 8.0.1 instead of 9.0.0.
Configuration
.NET 8
Windows 11 and Linux (Ubuntu)
x64
It's not specific to this configuration as far as I can tell.
Other information
No response
The text was updated successfully, but these errors were encountered:
This is same root cause as #109872. The fix will probably be available in January (we already fixed it in main). Only workaround right now is to target .NET 9.
Description
After upgrading the
Microsoft.Extensions.Hosting
nuget from8.0.1
to9.0.0
, I get the following error when running the executable compiled via AOT using source generation:Unhandled Exception: System.MissingMethodException: Method not found: 'Void System.Text.Json.Serialization.Metadata.JsonObjectInfoValues
1.set_ConstructorAttributeProviderFactory(System.Func1<System.Reflection.ICustomAttributeProvider>)'
The error does not happen with the previous versions, nor does it happen when compiled to a non-AOT executable using the latest version.
Reproduction Steps
Create the following minimalistic example project to test.
BugExample.csproj
Program.cs
Then run the following commands, assuming you are on Windows:
Expected behavior
The output should look like it does when using version
8.0.1
:EXPECTED OUTPUT
Actual behavior
Serialization fails with method not found:
ACTUAL OUTPUT
Regression?
The closest issue I could find from the past that was somewhat related to this was #61737. Seems to be something now that has changed with JsonObjectInfoValues in the latest version.
Known Workarounds
Use
8.0.1
instead of9.0.0
.Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: