How to hide GetType() method from COM?
- by ticky
I made an automation Add-In for Excel, and I made several functions (formulas).
I have a class which header looks like this (it is COM visible):
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
public class Functions
{}
In a list of methods, I see:
ToString(), Equals(), GetHashCode() and GetType() methods.
Since all methods of my class are COM visible, I should somehow hide those 4.
I succeeded with 3 of them:
ToString(), Equals(), GetHashCode()
but GetType() cannot be overriden.
Here is what I did with 3 of them:
[ComVisible(false)]
public override string ToString()
{
return base.ToString();
}
[ComVisible(false)]
public override bool Equals(object obj)
{
return base.Equals(obj);
}
[ComVisible(false)]
public override int GetHashCode()
{
return base.GetHashCode();
}
This doesn't work:
[ComVisible(false)]
public override Type GetType()
{
return base.GetType();
}
Here is the error message in Visual Studio when compile:
..GetType()': cannot override inherited member 'object.GetType()' because it is not marked virtual, abstract, or override
So, what should I do to hide the GetType() method from COM?