Reputation: 8394
For years I've had the faint memory that in C# the property Exception.Data
can be null
for some very specific exceptions (but I can't remember which). I've even built some extension methods to help around this problem. However, I just tried to find some documentation on this problem but couldn't find any.
Could it be that this was a thing some years ago (in an older .NET Framework version) but is no longer?
Upvotes: 2
Views: 404
Reputation: 8394
I managed to find the documentation I was remembering. It's in the ".NET Framework 4" offline help in Visual Studio (2017). Here the documentation for Exception.Data
contains an additional note:
The
ExecutionEngineException
,OutOfMemoryException
,StackOverflowException
andThreadAbortException
classes always return null for the value of the Data property.
Interestingly the online help for Exception.Data
is missing this note - but otherwise its contents seem to be the same as the offline help.
Update: I filed an issue for this inconsistency: https://github.com/dotnet/dotnet-api-docs/issues/4045
Upvotes: 4