FileConfigurationProvider.Load throws InvalidDataException
When Load() fails to load a file, it throws an InvalidDataException. If the file or directory doesn't exist, it throws a DirectoryNotFoundException or FileNotFoundException.
Version introduced
6.0 RC 1
Previous behavior
When loading failed, Load() did not throw an InvalidDataException.
New behavior
Starting in .NET 6, Load() throws an InvalidDataException if a file fails to load. In addition, the exception message includes the file path that failed to load.
Type of breaking change
This change can affect source compatibility.
Reason for change
This change improves the debugging experience. When a file fails to load, it's helpful to know which file failed to load.
Recommended action
If you are catching specific exceptions when calling Load(), make sure to also catch InvalidDataException.
Affected APIs
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for