COM Interop: Base class properties not exposed to COM

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,

I have a C# Class Libarary which is exposed to COM. The issue is base class members are not exposed to COM.As per msdn
<a title="http://msdn2.microsoft.com/en-us/library/8877bdk6%28VS.80%29.aspx http://msdn2.microsoft.com/en-us/library/8877bdk6(VS.80).aspx" rel=nofollow>http://msdn2.microsoft.com/en-us/library/8877bdk6(VS.80).aspx Managed Clas hierarchies flatten out when exposed as COM objects.
Please let me know how i can resove this issue. Thanks a lot in advance

Here is the sample Application Code:
The issue is base class member properties VehicleName ,Vehicle Type are not exposed to COM

<span style="font-weight:bold Base Class:
<div class=text style="padding-right:2px;padding-left:2px;background:rgb(252,252,252) 0% 50%;padding-bottom:2px;margin:0px;color:rgb(34,34,34);padding-top:2px
<ol>
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System.Collections.Generic;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System.Text;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System.Runtime.InteropServices;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace namespace ClassLibrary5
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     [Guid("99999999999A-CCCCc-ADDD-73444444E530")]
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     public interface IVehicle
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         bool Start();
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         bool Stop();
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         string VehicleName { get; set; }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         string VehicleType { get; set; }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     [Guid("4444444444444-1111-5555-44464445FF9")]
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     [ClassInterface(ClassInterfaceType.None)]
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     public abstract class Vehicle : ClassLibrary5.IVehicle
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         private string _VehicleName;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         private string _VehicleType;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public string VehicleName
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             get
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 return _VehicleName;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             set
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 _VehicleName = value;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public string VehicleType
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             get
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 return _VehicleType;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             set
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 _VehicleType = value;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public abstract bool Start();
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public abstract bool Stop();
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace        
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace } </ol>
<b>Derived class:</b>

<div class=smallfont style="margin-bottom:2px Code: ( text )
<div class=text style="padding-right:2px;padding-left:2px;background:rgb(252,252,252) 0% 50%;padding-bottom:2px;margin:0px;color:rgb(34,34,34);padding-top:2px
<ol>
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System.Collections.Generic;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System.Text;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace using System.Runtime.InteropServices;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace namespace ClassLibrary5
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     [Guid("00000000000-7771-8888-F8487777988")]
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     public interface ICar : IVehicle
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         string CarType { get; set; }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         int ModelNumber { get; set; }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         bool Start();
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         bool Stop();
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     [Guid("111111111-1234-1234-4567-C5077F131")]
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     [ClassInterface(ClassInterfaceType.None)]
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     public class Car : Vehicle, IVehicle, ICar
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         private int _ModelNumber;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         private string _CarType;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public int ModelNumber
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             get
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 return _ModelNumber;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             set
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 _ModelNumber = value;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public string CarType
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             get
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 return _CarType;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             set
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace                 _CarType = value;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace  
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public override bool Start()
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             //Start code goes here
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             return true;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         public override bool Stop()
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         {
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             //stop code goes here
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace             return true;
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace         }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace     }
<li style="font-size:8pt;background:rgb(252,252,252) 0% 50%
<div style="font-weight:normal;font-family:Courier New,Courier,monospace } </ol> Thanks,


View the full article
 
Back
Top