Open lizhihao132 opened 7 months ago
Hi @lizhihao132, it could be that you're building the project without reflection. Could you share a minimal project in a repo so we can test?
For reference, this needs to be in the h5.json file for reflection to work:
"reflection": {
"disabled": false
},
Issue Description: I've successfully built and run an H5 project following the instructions on the project's homepage. The project builds without errors using dotnet build, and I can start an HTTP server in the output directory to serve the application. Everything works fine in the browser until I add JSON serialization code to Program.cs.
Steps to Reproduce:
Expected Behavior: The application should serialize and deserialize a Person object to and from JSON without any errors, and the result should be logged to the console.
Actual Behavior: When opening the web page in the browser, I encounter the following JavaScript error: newtonsoft.json.js:340 Uncaught ctor {$init: {...}, message: 'Operation is not valid due to the current state of the object.', innerException: null, errorStack: Error: Operation is not valid due to the current state of the object.
Program.cs code as follows: