Game Development Reference
In-Depth Information
Finally, the following class implements the functionality of our COM component
that implements the IMyComponent interface. The ComSourceInterfaces attribute is
used to specify all the event source interfaces for our component.
using System.Windows.Forms;
public class MyComponent : IMyComponent
public void CustomMethod1()
// Do something useful
MessageBox.Show(“This was called from CustomMethod1()!”);
public int CustomMethod2()
return 1234;
public string CustomMethod3(string param)
return String.Format(“You entered the string: '{0}'!”, param);
The type library generator for .NET components does a fine job of wrapping
almost every type, though there are some rules to follow in order to ensure inter-
operability. These rules are:
Avoid using parameterized constructors and static methods.
Define interfaces for event sources in managed code.
Utilize HRESULT for user-defined exceptions.
Understand that differences in inheritance may occur.
Supply unique identifiers for appropriate types.
Following these rules will ensure that type library generation goes smoothly and is
utilized seamlessly.
Search Nedrilad ::

Custom Search