473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1277

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

Similar topics

4
by: Luke Briner | last post by:
My ActiveX Container requires certain properties to be exposed by components - properties that appear under the properties section in the IDL/type library file. C# properties are exposed as...
2
by: Zac | last post by:
Alright anyone who has 2c throw it in... I am working through a custom xml serializer and have come upon a conundrum, given our class design. The interface implemented on the base class (base...
0
by: Nadav | last post by:
Hi, Introduction: **************** I am writing a component based application, the application is built of several Native COM objects and some .NET classes exposed as COM objects by 'COM...
20
by: Razzie | last post by:
Hey all, I'm really going through a small hell right now - I've completely lost it :) I made a project, using two interop libraries from exchange (created them as in this msdn article:...
2
by: Andrew S. Giles | last post by:
OK, Ive run my head into this wall for too long. I need help. I am developing an applicaiton in C# to present a user with a GUI to specify a configurable list of machines that he wants to listen...
6
by: Microsoft | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
7
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
3
by: Jordan | last post by:
Suppose I have a system that keeps track of 5 different types of "People". My intent is to have a base Person class, then 5 derived classes for each of the specific person types (e.g., Patient,...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.