473,320 Members | 1,974 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,320 software developers and data experts.

Hidden interface

Fox
Hi all,

I would like to ask you a question regarding inheritence in C#.

I have a class which inherits from COM object, but then I want to pass
this class to the function expecting interface which COM object is
inherited from, I can't do it.

See sample:

C++ ATL project with COM interface A and COM object AInst
interface A
{
// some methods
}

class AInst : public A
{
// some methods
}

In C# I would like to do:
class AInstCSharp : public AInst
{
}

class B
{
public static void Do( A a )
{
//do something
}
}

Now somewhere in C# code:
AInstCSharp a = new AInstCSharp();

//next line will not compile due to an error CS1502
B.Do( a );

It seems that original interface A can't be used and also in object
browser I can't see that class AInstCSharp is inherited from A.
Do you have any idea how I can use it?

Fox
Nov 17 '05 #1
1 1063
Hi Fox,

For a default ATL COM object which inherits the interface A, it's
definition would be like:
class ATL_NO_VTABLE CA :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CA, &CLSID_A>,
public IDispatchImpl<IA, &IID_IA, &LIBID_PINT23Lib>
{
...

and when I tested the following code in a C# program, it is compiled OK:
public class AInstCSharp : AClass //the COM object CA
{
}

class B
{
public static void Do( A a ){}
}
...
AInstCSharp a = new AInstCSharp();
B b = new B();
B.Do(a);

...

I think the class AInst in your code snippet may be not a valid COM object,
so you cannot see the interface A in object browser.
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
2
by: Niels Knabe | last post by:
To simplify the user interface and to protect code I have unchecked the Tools|Options|View|Show Hidden objects. However, if a user selects displaying the hidden objects, I would like to reset this...
0
by: Jussi | last post by:
Hi! I have a COM server object in which I have set certain interfaces restricted/hidden. For example With VB client these attributes works as excpected. However if I use this same COM...
2
by: Me | last post by:
Is there anyway to control the style/layout of this field? ..NET doesn't generate an ID for it so you can create a style for it or manipulate it in code. I've looked on MSDN etc. but can't...
4
by: Joe | last post by:
Hello All: I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from a base class called BasePage.aspx. BasePage.aspx has no user interface but inherits System.Web.UI.Page...
6
by: =?Utf-8?B?L2Rldi9udWxs?= | last post by:
Hello, i am using visual studio 2003 enterprise architect version. I am making apps for the .Net framework 1.1. While testing an interface, i discovered something strange. In this application...
10
by: Bryan Parkoff | last post by:
I want this header file to be reused for client programmer. First of all, I divide my C code into Test.h and Test.c. Test.h is the interface. Test.c is the implementation. I place global...
1
by: Patient Guy | last post by:
I have a "hidden" anchor in the body of a doc. By "hidden," I mean that the contained text of the anchor is indistinguishable from the surrounding text, the text contained by its parent/ancestor...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.