Re: PInvokes with managed and unmanaged objects
From: James Lapalme (lapalmejames_at_hotmail.com)
Date: 02/09/04
- Next message: Paul Colton: "Call void* C func from C#..."
- Previous message: StevenDahlin: "Re: workbook.saveas() problem"
- In reply to: Zoiner Tejada: "Re: PInvokes with managed and unmanaged objects"
- Messages sorted by: [ date ] [ thread ]
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
>
- Next message: Paul Colton: "Call void* C func from C#..."
- Previous message: StevenDahlin: "Re: workbook.saveas() problem"
- In reply to: Zoiner Tejada: "Re: PInvokes with managed and unmanaged objects"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|