Unable to get usable data from System.__COMObject

2019-08-03 13:30发布

问题:

I am working with a third party SDK (Proprietary) which I have referenced in my console app, I been tasked to help build a solution which will facilitate many everyday tasks. However, as I been building one part of the solution I am observing that certain items return objects which to me looks like errors. This only happens with certain items, however other items return meaningful data, so I assume is related to it being null, or non existent. However I would like to ask the community for some insight.

Examples

When I look in to get a customer's binder GUID (Good Case)

string getGuid = currentWorkingPaper.ClientGUID; << I get meaningfull data that I can use

On the other hand when I look into accounts of the same customer binder (Bad Case)

 var value1 = currentWorkingPaper.RootEntity.Accounts; << returns {System.__ComObject}

When I drill down into {System.__ComObject} I get the following

My attempts to get data

I am tried to drill into get into this com object to see if I can get some information with the following actions but I am not getting any data that is usable.

First Attempt:

var whatIsThis1 = value1.GetType().GetMembers();

**Returns**

 -      whatIsThis1 {System.Reflection.MemberInfo[7]}   System.Reflection.MemberInfo[]
+       [0] {System.String ToString()}  System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
+       [1] {System.Object GetLifetimeService()}    System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
+       [2] {System.Object InitializeLifetimeService()} System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
+       [3] {System.Runtime.Remoting.ObjRef CreateObjRef(System.Type)}  System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
+       [4] {Boolean Equals(System.Object)} System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
+       [5] {Int32 GetHashCode()}   System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
+       [6] {System.Type GetType()} System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}

Second Attempt

var whatIsThis2 = value1.GetType().AssemblyQualifiedName;
**returns**
whatIsThis2 "System.__ComObject, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"   string

Third Attempt

var whatIsThis3 = value1.GetType().GetFields();
**Returns**
whatIsThis3 {System.Reflection.FieldInfo[0]}    System.Reflection.FieldInfo[]

Appendix

After my third attempt I see that it is returning no fields, so I assume that it may be, that when I get a System.__COMObject it is because I am trying to get data that is null or does not exist. Because, I only get these object with certain items which I am trying to get. However I am curious to see exactly what is inside of those com object.