Re: PInvokes with managed and unmanaged objects

From: James Lapalme (lapalmejames_at_hotmail.com)
Date: 02/09/04


Date: Mon, 9 Feb 2004 11:06:05 -0500

Thank you,

The reason I'm asking all theses questions is that I'm a grade student (C.S)
looking at different ways of reusing C/C++ libraries without
to much modification. I will explore the wrapping route after I get this one
down.

Where could I find more information on PInvokes when inheritences and
interfaces come into play?
I have readed many books on Com/.Net interop but they all limit themseftves
to basic types, strings and structs.
I have not found all the answers to my questions on the msdn site either.

JL

"Zoiner Tejada" <anonymous@discussions.microsoft.com> wrote in message
news:046943C9-0FE9-46CF-BB24-3A43BBDE2210@microsoft.com...
> > If I have a C++ class that use inheritence, I guess I must redefined in
C#
> all of its super classes?
>
> That's an interesting question and by interesting I mean hard to answer!
In reality the question I would ask first is if C++ is your favority
development language then why not just start using managed C++? I suppose
if this along the lines of your previous post, then what you are mainly
talking about is a C# wrapper class that encapsulates PInvoke calls to your
DLL. In this case, then yes you have to write all the DLLImport's for
whatever functions you need but you don't necessarily have to follow the
same inheritance as in C++ file, you get the priviledge of flattening the
hierarchy as you see fit.
>
> > Also, if I have a C++ class that uses multiple inheritence, is it
possible
> to represented in C# for PInvoke marshalling?If not any way around it?
>
> Because C# does not allow multiple inheritance, the only way to simulate
it is to use interfaces. This can be a workaround because, while you can
only inherit from one class at a time, you can implement multiple
interfaces.
>
> Happy Coding,
> Zoiner Tejada
>
>
> Visit my new VB.NET in 2D Guide for tips on calling the Win32 API using
PInvoke.
> http://www.tejadaz.com/VBdotNet
>



Relevant Pages

  • Re: The Language I want
    ... inheritance of interfaces from concrete types. ... packages may import, ... multiple inheritance ...
    (comp.lang.misc)
  • Re: Reprise: in out parameters for functions
    ... > 2) multiple inheritance would be supported; ... interfaces; is true for calls through interfaces (as opposed to directly ... adding protected and task support to them is not a ...
    (comp.lang.ada)
  • Re: Extension methods almost allow multiple inheritance via mixins (but not quite)
    ... What you really want is true multiple inheritance ... not interfaces extended with fields. ... Anything you can do with extension methods you can do with static methods, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: High performance alternative to MI of virtual bases
    ... > modeling IS-A relationships is incorrect. ... candidates for interfaces, in either the pure ABC or HFront sense. ... inheritance hierarchy, at least conceptually. ... "People quite correctly say that you don't need multiple inheritance, ...
    (comp.lang.cpp)
  • Re: The Language I want
    ... inheritance of interfaces from concrete types. ... Generics is a huge mess. ... Templates or hygenic macros are not generics! ...
    (comp.lang.misc)