Game Development Reference
In-Depth Information
[DispId(2)]
int CustomMethod2();
[DispId(3)]
string CustomMethod3(string param);
}
Okay, I lied. The most important attribute is ComVisible , which identifies a class or
interface within an assembly as a COM object when registered. Adding a
ComVisible(true) attribute to a class or interface exposes the type to COM. The fol-
lowing code shows the source code for the.NET-based COM component for the
accompanying example. The first code snippet describes the interface that clients
can communicate to the object with.
[Guid(“AB8C32F0-9DA1-4afb-8B91-E8B035412DBD”),
ComVisible(true)]
public interface IMyComponent
{
[DispId(1)]
void CustomMethod1();
[DispId(2)]
int CustomMethod2();
[DispId(3)]
string CustomMethod3(string param);
}
The next code snippet describes the event source interface that would serve more
of a purpose if the accompanying example used COM events. We cannot use reg-
ular .NET event delegates with a regular COM client, so we will not cover COM
events aside from showing how to register the event source interface.
[Guid(“50B39BFD-FC05-4f28-AF75-084E0394A55E”),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch),
ComVisible(true)]
public interface IMyComponentEvents
{
// This is where events would be defined.
// This example does not use them
}
Search Nedrilad ::




Custom Search