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

Improve .NET Native AOT failure message when missing types in rd.xml #479

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

Rosalie241
Copy link
Contributor

@Rosalie241 Rosalie241 commented Feb 13, 2024

I was playing around with AOT in .NET 8 and when missing a type in rd.xml, it'd show the following exception which confused me:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.LoadAssetReaders(ContentReader) + 0x8e5
   at Microsoft.Xna.Framework.Content.ContentReader.InitializeTypeReaders() + 0x4e
   at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]() + 0x1f
   at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String, Action`1) + 0x194
   at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) + 0xc6

so to aid developers like myself in the future, I've changed the exception to be the following:

Unhandled Exception: System.InvalidOperationException: Failed to get constructor for ContentTypeReader. If you're using .NET Native AOT, ensure your rd.xml contains the following type: Microsoft.Xna.Framework.Content.StringReader
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.LoadAssetReaders(ContentReader) + 0x8e5
   --- End of inner exception stack trace ---
   at Microsoft.Xna.Framework.Content.ContentTypeReaderManager.LoadAssetReaders(ContentReader) + 0xb7a

@flibitijibibo flibitijibibo merged commit 353fbca into FNA-XNA:master Feb 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants