Why can't a null-reference exception name the object that has a null reference?

前端 未结 5 2172
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 15:48

It seems to me that a lot of my debugging time is spent chasing down null-reference exceptions in complex statements. For instance:

For Each game As IHomeGam         


        
5条回答
  •  独厮守ぢ
    2020-12-17 16:35

    In release builds, the variable names are stripped out from the symbols and the code might even be optimized to not have a specific memory location for a variable, but just keep the reference in one of the registers (depending on the scope of the variable usage). Thus, it might not be possible to deduct the name of the variable from the reference location.

    In debug build, there's more information available about the variables. However, the exception object needs to work the same way irregardless of the build flavor. Hence, it acts upon the minimum information it can access in any flavor.

提交回复
热议问题