How to make GetType for COM invisible

10/09/2007 - 09:35 von Norbert Pürringer | Report spam
Hello there,

how can I make the GetType function for COM invisible?

My problem is following:

I want to implement an interface to provide a COM object. This
interface was already implemented several times in C++ or VB, where
the COM functions have strictly defined Dispids.

If I now implement a COM object via C#, the functions of a normal C#
object are part of the COM object too. Those are

ToString, Equals, GetHashCode and GetType.

It's no problem to set the COMVisible attribute of ToString, Equals
and GetHashCode to False, as these functions can be overriden without
any problems. But GetType cannot be overriden due to not having the
virtual keyword.

What can be done to avoid exporting the GetType function in a .NET COM
object having an interfering Dispid?

Regards,
Norbert
 

Lesen sie die antworten

#1 Oliver Denter
12/09/2007 - 18:23 | Warnen spam
Norbert Pürringer schrieb:
Hello there,

how can I make the GetType function for COM invisible?

My problem is following:

I want to implement an interface to provide a COM object. This
interface was already implemented several times in C++ or VB, where
the COM functions have strictly defined Dispids.

If I now implement a COM object via C#, the functions of a normal C#
object are part of the COM object too. Those are

ToString, Equals, GetHashCode and GetType.

It's no problem to set the COMVisible attribute of ToString, Equals
and GetHashCode to False, as these functions can be overriden without
any problems. But GetType cannot be overriden due to not having the
virtual keyword.

What can be done to avoid exporting the GetType function in a .NET COM
object having an interfering Dispid?

Regards,
Norbert



Hi,

is this possible?


namespace ClassLibrary1
{
[ComVisible(true)]
public class Class1
{

public string GetSTring()
{
return "Hallo";
}

[ComVisible(false)]
public new object GetType()
{
return null;
}
}
}

Ähnliche fragen