Creating COM components in .NET

In this blog I create a COM application for Amazon Marketplace Web Services (Amazon MWS).

COM is a platform-independent, distributed, object-oriented system for creating binary software components that can interact. COM is the foundation technology for Microsoft's OLE (compound documents) and ActiveX (Internet-enabled components) technologies. 

Step 1: Create Class Library project.  Add Interface and  call in your class.

[Guid("321A78B5-53F6-499A-9333-1A18A1A87F1B")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
 [ComVisible(true)]
 public interface IAmazonService
 {
  }
[Guid("29C0007F-ED96-4141-986C-A50DA1AC3CAD")]
[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
public class AmazonOrderService : IAmazonService
{
}
 

You must be defining all the property and Methods you need to create are public.

[Guid("321A78B5-53F6-499A-9333-1A18A1A87F1B")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [ComVisible(true)]
    public interface IAmazonService
    {
        [DispId(1)]
        string Serviceurl { get; set; }
        [DispId(2)]
        string Signaturemethod { get; set; }
        [DispId(3)]
        string Signatureversion { get; set; }
        [DispId(4)]
        string ApplicationName { get; set; }
        [DispId(5)]
        string Applicationversion { get; set; }
        [DispId(6)]
        string Awsaccesskeyid { get; set; }
        [DispId(7)]
        string Awssecretaccesskey { get; set; }
        [DispId(8)]
        string Sellerid { get; set; }
        [DispId(9)]
        string Marketplaceid { get; set; }
        [DispId(10)]
        string Createdafter { get; set; }
        [DispId(11)]
        string Createdbefore { get; set; }
        [DispId(12)]
        string Lastupdatedafter { get; set; }
        [DispId(13)]
        string Lastupdatedbefore { get; set; }
        [DispId(14)]
        string Issetorderstatus { get; set; }
        [DispId(15)]
        string Separatedvalues { get; set; }
        [DispId(16)]
        string AmazonOrderId { get; set; }
        [DispId(17)]
        object GetListOrders();
        [DispId(18)]
        object GetListOrderItems();
    }

    [Guid("29C0007F-ED96-4141-986C-A50DA1AC3CAD")]
    [ClassInterface(ClassInterfaceType.None)]
    [ComVisible(true)]

    public class AmazonOrderService : IAmazonService
    {
        MarketplaceWebServiceOrdersConfig mwsOrderConfig = new MarketplaceWebServiceOrdersConfig();
        MarketplaceWebServiceOrdersClient mwsOrderClient;
        ListOrdersRequest request;
        ListOrderItemsRequest orderitemrequst;
        IDictionary<String, String> parameter;
        private string[] mwsMarketplaceIdList;
        private string _serviceurl;
        private string _signaturemethod;
        private string _signatureversion;
        private string _applicationName;
        private string _applicationversion;
        private string _awsaccesskeyid;
        private string _awssecretaccesskey;
        private
string _action;
        private string _sellerid;
        private string _createdafter;
        private string _createdbefore;
        private string _lastupdatedafter;
        private string _lastupdatedbefore;
        private string _issetorderstatus;
        /// <summary>
        /// If multipal then pass string with separated values
        /// </summary>      
        private string _marketplaceid;
        private string _separatedvalues;
        private string _amazonorderid;
        public string Serviceurl
        {
            get { return _serviceurl; }
            set { _serviceurl = value; }
        }
        public string Signaturemethod
        {
            get { return _signaturemethod; }
            set { _signaturemethod = value; }
        }
        public string Signatureversion
        {
            get { return _signatureversion; }
            set { _signatureversion = value; }
        }
        public string ApplicationName
        {
            get { return _applicationName; }
            set { _applicationName = value; }
        }
        public string Applicationversion
        {
            get { return _applicationversion; }
            set { _applicationversion = value; }
        }
        public string Awsaccesskeyid
        {
            get { return _awsaccesskeyid; }
            set { _awsaccesskeyid = value; }
       }

       public string Awssecretaccesskey

        {

           get { return _awssecretaccesskey; }

           set { _awssecretaccesskey = value; }

        }
        public string Action
        {
            get { return _action; }
            set { _action = value; }
        }
        public string Sellerid
        {
            get { return _sellerid; }
            set { _sellerid = value; }
        }
        public string Createdafter
        {
            get { return _createdafter; }
            set { _createdafter = value; }
        }
        public string Createdbefore
        {
            get { return _createdbefore; }
            set { _createdbefore = value; }
        }
        public string Lastupdatedafter
        {
            get { return _lastupdatedafter; }
            set { _lastupdatedafter = value; }
        }
        public string Lastupdatedbefore
        {
            get { return _lastupdatedbefore; }
            set { _lastupdatedbefore = value; }
        }
        public string Issetorderstatus
        {
            get { return _issetorderstatus; }
            set { _issetorderstatus = value; }
        }
        public string Marketplaceid
        {
            get { return _marketplaceid; }
            set { _marketplaceid = value; }
        }
        public string Separatedvalues
        {
            get { return _separatedvalues; }
            set { _separatedvalues = value; }
        }
        public string AmazonOrderId
        {
            get { return _amazonorderid; }
            set { _amazonorderid = value; }
        }
        public object GetListOrders()
        {
               //Your code.
        }
        public object GetListOrderItems()
        {
           //Your code.
        }      
}

For more Details download the Code.

Reference http://msdn.microsoft.com/en-us/library/ee663262%28v=VS.85%29.aspx