469,645 Members | 1,656 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

COM Interop: Base class properties not exposed to COM

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
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

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace ClassLibrary5
  7. {
  8.     [Guid("99999999999A-CCCCc-ADDD-73444444E530")]
  9.     public interface IVehicle
  10.     {
  11.         bool Start();
  12.         bool Stop();
  13.         string VehicleName { get; set; }
  14.         string VehicleType { get; set; }
  15.     }
  16.  
  17.     [Guid("4444444444444-1111-5555-44464445FF9")]
  18.     [ClassInterface(ClassInterfaceType.None)]
  19.     public abstract class Vehicle : ClassLibrary5.IVehicle
  20.     {
  21.         private string _VehicleName;
  22.         private string _VehicleType;
  23.  
  24.         public string VehicleName
  25.         {
  26.             get
  27.             {
  28.                 return _VehicleName;
  29.             }
  30.             set
  31.             {
  32.                 _VehicleName = value;
  33.             }
  34.         }
  35.  
  36.         public string VehicleType
  37.         {
  38.             get
  39.             {
  40.                 return _VehicleType;
  41.             }
  42.             set
  43.             {
  44.                 _VehicleType = value;
  45.             }
  46.         }
  47.  
  48.         public abstract bool Start();
  49.         public abstract bool Stop();
  50.  
  51.  
  52.     }
  53. }


Derived class:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace ClassLibrary5
  7. {
  8.     [Guid("00000000000-7771-8888-F8487777988")]
  9.     public interface ICar : IVehicle
  10.     {
  11.         string CarType { get; set; }
  12.         int ModelNumber { get; set; }
  13.         bool Start();
  14.         bool Stop();
  15.     }
  16.  
  17.     [Guid("111111111-1234-1234-4567-C5077F131")]
  18.     [ClassInterface(ClassInterfaceType.None)]
  19.     public class Car : Vehicle, IVehicle, ICar
  20.     {
  21.         private int _ModelNumber;
  22.         private string _CarType;
  23.  
  24.         public int ModelNumber
  25.         {
  26.             get
  27.             {
  28.                 return _ModelNumber;
  29.             }
  30.             set
  31.             {
  32.                 _ModelNumber = value;
  33.             }
  34.         }
  35.  
  36.         public string CarType
  37.         {
  38.             get
  39.             {
  40.                 return _CarType;
  41.             }
  42.             set
  43.             {
  44.                 _CarType = value;
  45.             }
  46.         }
  47.  
  48.         public override bool Start()
  49.         {
  50.             //Start code goes here
  51.             return true;
  52.         }
  53.         public override bool Stop()
  54.         {
  55.             //stop code goes here
  56.             return true;
  57.         }
  58.     }
  59. }


Thanks,
Oct 3 '07 #1
0 1135

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Luke Briner | last post: by
2 posts views Thread by Zac | last post: by
reply views Thread by Nadav | last post: by
2 posts views Thread by Andrew S. Giles | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.