Game Development Reference
Figure 32.2 Communication between a client and a .NET object through a COM Callable Wrapper.
An additional layer of overhead is introduced to your application when using
COM Interop, but this penalty is typically quite small and often unnoticeable. The
biggest performance bottleneck comes from marshaling between wrappers and
environments. So if you suspect that your performance problems are coming from
COM Interop, verify this by creating a COM worker class to wrap your chatty calls
into a single function that can be invoked by your managed application; doing so
will decrease the amount of marshaling between the two layers.
Applying Interop Attributes
Exposing .NET components as COM objects is nearly autonomous, though there
are some attributes that must be decorated on exposed classes so that COM can
understand them correctly.
COM relies on identifying public components through the Windows registry, so
perhaps the most important attribute is decoration of unique identifiers on all
exposed classes and interfaces. This is done with the Guid attribute, as shown in the
public interface IMyComponent
You can easily create unique identifiers for your types with the Tools->Create
GUID->Registry Format menu item in the Visual Studio IDE. Globally unique
identifiers ( GUID ) are the equivalent of CLSID s. Also good to know, you can set a
humanly readable form of the unique identifier using the ProgId attribute, although
the accompanying example does not use it.