-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JsonSerializerOptionsNoTypeInfoResolverSpecified after upgrading from .NET 8 Preview 6 to 7 (release mode only) #90395
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionApp works fine in debug mode for both Preview 6 and 7. Codebase: private readonly HttpClient httpClient;
private readonly JsonSerializerOptions jsonSerializerOptions;
public HttpClientDocumentService(HttpClient httpClient)
{
this.httpClient = httpClient;
jsonSerializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
}
public async Task<ResponseDTO<IReadOnlyCollection<DocumentListDTO>>> GetDocumentListAsync(DocumentFilter documentFilter, CancellationToken cancellationToken = default)
{
try
{
HttpResponseMessage response = await httpClient.PostAsJsonAsync("Document/GetDocumentList", documentFilter, jsonSerializerOptions, cancellationToken);
return await response.Content.ReadFromJsonAsync<ResponseDTO<IReadOnlyCollection<DocumentListDTO>>>(jsonSerializerOptions, cancellationToken) ?? new ResponseDTO<IReadOnlyCollection<DocumentListDTO>>(false, "Der skete en serverfejl, kontakt os hvis problemet fortsætter.");
}
catch (OperationCanceledException ex)
{
return new ResponseDTO<IReadOnlyCollection<DocumentListDTO>>(false, "Din anmodning blev annulleret.", ErrorType.General_OperationCanceled, ex.Message, ex.InnerException?.Message);
}
catch (Exception ex)
{
return new ResponseDTO<IReadOnlyCollection<DocumentListDTO>>(false, "Der opstod en fejl ved din behandling - prøv igen eller kontakt os.", ErrorType.General_Unhandled, ex.Message, ex.InnerException?.Message);
}
} My app worked fine in .NET 8 Preview 6: After upgrading to .NET 8 Preview 7: Seems like a JsonSerializer bug in the .NET Preview 7 install package. I tried these:
Steps to Reproduce
Link to public reproduction project repositoryNo response Version with bug8.0.0-preview.7.8842 Is this a regression from previous behavior?Yes, this used to work in .NET MAUI Last version that worked well8.0.0-preview.6.8686 Affected platformsAndroid, I was not able test on other platforms Affected platform versionsAndroid 13, not tested on other. Did you find any workaround?Change back to previous SDK: .NET 8 Preview 6. Relevant log outputNo response
|
Appears to be a duplicate of dotnet/maui#16038. Setting <JsonSerializerIsReflectionEnabledByDefault>true</JsonSerializerIsReflectionEnabledByDefault> in your project should get you back the original behavior. |
@eiriktsarpalis That worked, thanks. When will this be fixed, and after fix can I remove that line? in .NET 8 RC1? |
@DM-98 I would recommend subscribing to dotnet/maui#16038 for updates on the issue. |
Description
App works fine in debug mode for both Preview 6 and 7.
App crashes in release mode for just Preview 7: JsonSerializerOptionsNoTypeInfoResolverSpecified.
My app worked fine in .NET 8 Preview 6:
![DebugMode](https://private-user-images.githubusercontent.com/10290906/260047642-4f74cf99-fc91-403c-a0bf-e56663ab8a68.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MTY3OTcsIm5iZiI6MTczODgxNjQ5NywicGF0aCI6Ii8xMDI5MDkwNi8yNjAwNDc2NDItNGY3NGNmOTktZmM5MS00MDNjLWEwYmYtZTU2NjYzYWI4YTY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDA0MzQ1N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY3MGIxMTRhZDc1ZjlkNjQwNGY4MjY3MzhmOGMzODdiMWM4ODVkMTUxZmMwNjcyYjA1ZjU0OTA0ZWZlZTdlNzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ipIk6PVEMMB5RTN8wHc3GyHZomkrfeEfJWYOsDXccJM)
After upgrading to .NET 8 Preview 7:
![ReleaseMode](https://private-user-images.githubusercontent.com/10290906/260047660-0c651b2a-993f-484d-a824-7474cb327705.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MTY3OTcsIm5iZiI6MTczODgxNjQ5NywicGF0aCI6Ii8xMDI5MDkwNi8yNjAwNDc2NjAtMGM2NTFiMmEtOTkzZi00ODRkLWE4MjQtNzQ3NGNiMzI3NzA1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA2VDA0MzQ1N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBiYmZkY2RkMmU5ZDVjODIwZWQ5ZTU5MTA5NGJkMzhhYmU5OTgxNmI5ZDM1ZGEwZDM3NmI0NTkwZWQwMDA2NzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.M99BQPOo-fwn-SYBOCpHBf0W1wmktyxIBOzmUc_eaM4)
Seems like a JsonSerializer bug in the .NET Preview 7 install package. I tried these:
Steps to Reproduce
Link to public reproduction project repository
https://github.com/DM-98/MauiApp1
Version with bug
8.0.0-preview.7.8842
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.0-preview.6.8686
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
Android 13, not tested on other.
Did you find any workaround?
Change back to previous SDK: .NET 8 Preview 6.
Edit (workaround by eiriktsarpalis):
Relevant log output
No response
The text was updated successfully, but these errors were encountered: