473,756 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

COM Interop: Base class properties not exposed to COM

1 New Member
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 1315

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

Similar topics

4
6820
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 methods and the interfaces that my c# class implements cannot contain fields in order to expose these as properties. Can anyone tell me how to expose c# code as COM (IDL) properties. Thanks
2
2564
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 for all business entities) dictates that the implementing class expose a Dirty property (for state). The base class (that actually manages state, once for all inheritors)
0
367
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 Interop', all of the objects expose an interface of the same type. Following are some important points to take in mind while reading this post: 1. The consumer of the interface/s is written in native code ( not ..NET*.* ) so COM interfaces are used for...
20
3195
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsmtps/html/writingmngsinks.asp). I set my project properties as 'Register as COM interop' to true, I can install it my project on my developement machine without a flaw. Great.
2
1991
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 to the output of. Specify a filename to shove all of the data (into Excel), and start the whole thing going. I get that done no problem. The problem comes with the Data. The data is coming from a different application, and I am not 100% sure of...
6
6663
by: Microsoft | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
7
6625
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
3
5337
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, Doctor, Employee, Contractor, etc). Now, at runtime I need to retrieve all the property values from a database and populate all of the fields of both the base and derived classes. Not all fields will need to be exposed via public properties as...
26
5374
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 because I am not always able to control/create all the different constructors the base class has. My problem can be described in code as follows ... /* This is the base class with a whole heap of constructors/functionality*/ public class Animal
0
9431
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.