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
Serialize/Deserialize not working in Release build #2912
Comments
"Not working" is not an adequate description of the problem you are observing. It's just merely stating the result of the problem you observed. If you did not observe anything (i.e., the "actual behavior") besides being able to state "not working", then you you need to do more debugging and troubleshooting to gather more relevant information about your problem.
The Newtonsoft.Json library has no mechanism or features imposing or enforcing licensing restrictions. If there is anything on your end indicating a licensing issue, it's not related to the Newtonsoft.Json library itself. Just a shot from my hip and the only one speculation i am willing to do here given the scarce problem description: Often, the default build settings for mobile targets include code trimming and perhaps even Native AOT compiling. Newtonsoft.Json, being a library whose functionality mostly depends on reflection, does not gel well with code trimming or Native AOT compiling. Therefore, i'd suggest to verify your build settings and try explicitly disabling code trimming and Native AOT compiling. If this is not possible/feasible or does not resolve the problem, i'd suggest you give System.Text.Json a try, since System.Text.Json is much less dependent on reflection and therefore a better and more natural fit for projects involving code trimming and/or native AOT compiling. |
@elgonzo - well, being in release I'm not seeing actual error generated. AND this all works in Debug mode. You have however pointed me in a good direction to investigate and linking and AOT are highly likely the problem. Thx |
I assume "not returing any objects" means that |
I don't know enough about the linker and trimming directives for the csproj. and the VS UI gives limited control on the project. Are there any directives similar to this to negate the issue effecting .Json?
Thx |
Disabling NativeAOT for iOS might be a bit trickier, and i unfortunately have no experience regarding .NET stuff on iOS. I don't know if .NET's iOS targets still rely on Xamarin.iOS under the hood and supports the mono interpreter. However, as it seems, disabling native AOT compiling for iOS targets requires enabling the mono interpreter. See here for details: https://learn.microsoft.com/en-us/dotnet/maui/macios/interpreter If this is too difficult to setup correctly (don't ask me how), perhaps switching to |
You help and advice is excellent! Thanks for pointing me in good directions! |
@elgonzo - update.
Had to deal with the Serialize too. So all is good for now. And it all works! Thanks for your responses, insight and guidance! |
I have a Maui app project targeting Android and iOS.
The Android version using latest Json libraries is live and running. All works in both debug and release mode.
VS 2022 (latest version), NewtonSoft.Json version 13.0.3, Maui targeting .Net7
The iOS version works in Debug mode but won't serialize/deserialise objects when compiled in Release mode.
I'm not sure if this is a bug or a licensing issue for the iOS platform but this all works in the Android targeted app, both in Build and Release mode. Exactly same codebase AND the Android version is also obfuscated in Release mode.
Expected behavior
Serialize/Deserialize objects in Release build.
Actual behavior
Steps to reproduce
The text was updated successfully, but these errors were encountered: