472,779 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 1243

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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.