You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improving Developer Experience for InvalidOperation_NoValue Error Message in Nullable<T> #126560
Description:
The current error message for reading an empty Nullable.Value is highly counter-intuitive and misleading.
In src/libraries/System.Private.CoreLib/src/Resources/Strings.resx, the InvalidOperation_NoValue string is defined as:
"Nullable object must have a value."
The Problem: > This phrasing incorrectly implies that developers must assign a value to a nullable object. However, the alternative is simply not to access it via the .Value property. The message points to the state of the object, rather than the invalid action (accessing .Value without checking .HasValue), which confuses developers and causes unnecessary debugging time.
Proposed Solution:
Update the resource string to reflect the action requirement rather than an object state requirement.
Change from: "Nullable object must have a value."
Change to: "Nullable object must have a value to access by Value property."
(Or something similar like: "Cannot read the Value property of a null Nullable object.")
This minor string update in Strings.resx will significantly improve DX and save countless hours of confusion for developers encountering this InvalidOperationException.
I like that alternate form of "Cannot read the Value property of a null Nullable object." and we might have an existing message along these lines somewhere else that we can match or reuse.
Activity
dotnet-policy-service commentedon Apr 5, 2026
Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.
jeffhandley commentedon Aug 16, 2026
I like that alternate form of "Cannot read the Value property of a null Nullable object." and we might have an existing message along these lines somewhere else that we can match or reuse.
Make the Nullable<T>.Value exception message actionable (#132367)
[release/11.0] Make the Nullable<T>.Value exception message actionable (