What is the _xcode field of the .NET Exception type?

帅比萌擦擦* 提交于 2020-01-03 16:57:21

问题


In my unit tests I need to perform deep equality tests of two objects, which are expected to be identical. During the tests I discover some interesting fields in system types that break my code. Exception._xcode is the most recent one. Here are a couple of facts about this field:

  1. It is initialized to -532459699 in all the Exception constructors, except the custom deserialization constructor, where it is simply never mentioned (thanks Reflector).
  2. It is not marked with the NonSerialized attribute.

Given these facts, the field is reset to 0 after an Exception object is deserialized, which is certainly different from what it is set to in constructors.

I am wondering what is the raison d'être of this field?

Thanks.


回答1:


This field is used to store COM+ exception codes and it's value is assigned to the constant _COMPlusExceptionCode.



来源:https://stackoverflow.com/questions/1935166/what-is-the-xcode-field-of-the-net-exception-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!