Jonathan Allen
Jonathan Allen

Reputation: 70307

.NET: How do I determine if an object is a COM object?

How do I determine if an object is a COM object? I need to call Marshal.FinalReleaseComObject on all COM objects in an array of type Object.

Upvotes: 7

Views: 309

Answers (3)

Yuriy Faktorovich
Yuriy Faktorovich

Reputation: 68687

typeof(myObject).IsCOMObject

or

instanceOfMyObject.GetType().IsCOMObject

Upvotes: 5

Nick
Nick

Reputation: 5955

You can call GetType() and inspect the IsCOMObject property

Upvotes: 2

David Morton
David Morton

Reputation: 16505

Marshal.IsComObject

Upvotes: 8

Related Questions