I have a COMVisible class MyAPI that my clients are going to use as the root object for all API access.
I have my APIs in another assembly OtherAPI that has Document and Window API classes (not COM visible).
I want to expose Document and Window classes via MyAPI class to a late binding client such as JavaScript.
[COMVisible(true)]
class MyAPI
{
public OtherAPI::Document NewDocument()
{
return new OtherAPI::Document();
}
}
// Something like this should work in the client code
(new MyAPI()).NewDocument().GetName();
The problem is that it does not see GetName because that is not COM visible I think.
I can wrap each and every function from Document and Window class in this class but I am looking for an elegant solution. I want my clients app to be able to use both Document and Window class functions via MyAPI object.
You need to read the documentation...
Important parts highlighted for you viewing pleasure :)
ComVisibleAttribute Class
However!
So it reads very clearly.
If you have marked the parent class members to false you cant expose them, however if its only the parent class that as been marked false (and the member aren't explicitly marked false), you can expose them.
Otherwise, you will have to re-implement them all again... Sorry, no free lunch here today