Showing results for 
Search instead for 
Did you mean: 

PropertyInfo is always Nothing


I am checking if a selected Solid Edge object has the "Key" property.

For this I am using:


Dim oSelSet As SelectSet = oDoc.SelectSet
Dim o As Object = oSelSet.Item(1)
Dim oPIinfo As _PropertyInfo = o.GetType().GetProperty("Key")
If oPIinfo IsNot Nothing Then
End If


For eg. a Line2d has a Key property but a CoordinateSystem does not.

But oPInfo is always Nothing.


Kindly suggest how to overcome this problem.





This does not seem to happen with non-SE objects like, say a TextBox, which returns the info when seeking the "Text" property and Nothing for a property called "Tex" using GetProperty.



Re: PropertyInfo is always Nothing

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom



Because of the way .NET COM Interop works, your o.GetType() will always return System.__ComObject. To check yourself, simply assign the return value of GetType() to a variable and look in the watch window.


This issue is already addressed in the SolidEdge.Community NuGet package as shown below.


static void Main(string[] args)
    var application = SolidEdgeCommunity.SolidEdgeUtils.Connect();
    var selectSet = application.ActiveSelectSet;
    var item = selectSet.Item(1);
    // Because of .NET COM Interop, this will always be System.__ComObject.
    var rcwType = item.GetType();

    // Use the following approach to resolve the actual runtime type.
    var type = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(item);

    var propertyInfo = type.GetProperty("Key");

    if (propertyInfo != null)
        // Property exists.


If you don't want to use that NuGet package, you can always figure out how to do it yourself by looking at my ComObject.cs on GitHub. If you need help converting the C# code to VB, I use Instant VB from Tangible Software Solutions.

Jason Newell
Applications Architect

Re: PropertyInfo is always Nothing


Thanks Jason, I did suspect the System.__ComObject must be hiding the property.