Reputation: 7618
What is an equivalent implementation of the method System.Type.IsEquivalentTo
that reproduces the same internal logics in C# .Net 3.5 or older?
Upvotes: 0
Views: 656
Reputation:
In older versions of .NET Framework, two distinct types are never equivalent, so the whole method doesn't make sense. If the method returns true
for two distinct COM types, it's supposed to indicate that you can cast from one of those COM types to the other (because in the COM world, they're the same type). Prior to .NET 4, you simply can't do that, you'll get an exception.
Depending on what you're after, you can either inspect the types' GUIDs (which won't help you get any conversion working), or use ==
for comparison (which indicates two different COM wrapper classes are not the same type).
Upvotes: 1
Reputation: 8821
Have a look at the source code and go from there. Looking at the base implementation there seems to be nothing exciting going on. There may be more here but that's as deep as the rabbithole goes on referencesource.microsoft.com
I guess.
Upvotes: 3