The IntelliSense popup (also known as "DataTip") allows you to analyze the object using the actual underlying type that the inspected object has. It will then use reflection to display and expose everything that object has to offer, regardless of the type of the inspected variable.
The Immediate Window allows you to execute bits of code as if you had written them in your own code. This code however must respect the declared type of the variables in the current scope.
You have several options here:
If you want to use the properties in your actual code, it's best to actually catch the specific exception type you want to handle. If applicable, you may also use a common superclass. For example, you can use catch (OperationCanceledException ex)
to catch any OperationCanceledException
, as well as the derived TaskCanceledException
. In that case, ex
will give you access to everything from OperationCanceledException
and its superclasses, but not from things specific to derived classes. This is actually what you did there, but by chosing the most broad superclass System.Exception
, there isn't really much specific insight ex
can offer, apart from all things that the Exception
class already introduced at the top level of the type hierarchy.
If you only want to inspect it temporarily within the immediate window, you can add a simple cast to the code line in your immediate window: ((ODataError) ex).Error.Message
Or, depending on your usings (which are also inherited from the local context), you may need to fully reference it, like so: ((Microsoft.Graph.Models.ODataErrors.ODataError) ex).Error.Message
ex.Error
, if a different exception type ended up being thrown?catch (ODataError ex) { ... }
as firstcatch
because theError
property is specific toODataError
and not available inException
. You can add a second catch catching any nonODataError
withcatch (Exception ex)
.