Software & Finance

C# - Step 5 Define Interface and Implement Class


There are 3 COM interface type listed below:

ComInterfaceType.InterfaceIsIUnknown - This COM interface type supports only early binding.

ComInterfaceType.InterfaceIsIDispatch - This COM interface type supports only late binding.

ComInterfaceType.InterfaceIsDual - COM interface types supports both IDispatch and IUnknown mode.


There are 3 ClassInterfaceType listed below:


ClassInterfaceType.None (No class interface will be generated so that COM clients need always to go through the interface explicitly defined in our case it is IMathCtrl.

ClassInterfaceType.AutoDispatch (for dispinterface for the class used in late binding for COM Client)

ClassInterfaceType.AutoDual (Discouraged to use since it might produce versioning conflicts and compilation problems)


The sample interface definition is given on this below: 


using System;

using System.Runtime.InteropServices;


namespace SFTCSServer




    public interface IMathCtrl



        int AddNumbers(int a, int b);






    public class MathCtrl : IMathCtrl


        public MathCtrl() { }


        public int AddNumbers(int a, int b)


            return (a+b);



        public int MuliplyNumbers(int a, int b)


            return (a * b);





Back to Index of Steps for C# class Library Server and C++ Index


Click here to download the complete source code of C# Class Library Server and C++ Client