Re: PInvoke a legacy class?
From: Tim Johnson (tjohnson_at_high-point.com)
Date: 08/18/04
- Next message: Shrage H. Smilowitz: "Re: How can i load a csv file into a dataset in .Net Compact framework"
- Previous message: Peter Foot [MVP]: "Re: PInvoke a legacy class?"
- In reply to: Peter Foot [MVP]: "Re: PInvoke a legacy class?"
- Next in thread: Alex Feinman [MVP]: "Re: PInvoke a legacy class?"
- Reply: Alex Feinman [MVP]: "Re: PInvoke a legacy class?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 18 Aug 2004 13:54:45 -0700
Thanks for the info. But how do I come up with the right full mangled name
from a dumpbin output? For example the "void Disconnect();" method of my
CStack class is reported as:
18 11 000052BC ?Disconnect@CStack@@QAAXXZ
Which parts actually constitute the mangled name DllImport is looking for?
-- Tim Johnson High Point Software www.high-point.com (503) 312-8625 "Peter Foot [MVP]" <feedback@nospam-inthehand.com> wrote in message news:eDyMy9VhEHA.556@tk2msftngp13.phx.gbl... > You can P/Invoke to C++ functions with decorated names only if they are > static functions, if they are instance members you can't, because > instantiating a C++ class from managed code is not possible. > > If the functions are static, your only hurdle is to include the EntryPoint > property of the DllImport attribute to the full mangled name of the method / > or the numeric ordinal - you can use dumpbin or depends to find out this > information. > > You could write a native C++ dll which would expose a single method which > created the class, called the method and then called the destructor, you can > then P/Invoke this from managed code. > > Peter > > -- > Peter Foot > Windows Embedded MVP > www.inthehand.com | www.opennetcf.org > > Do have an opinion on the effectiveness of Microsoft Windows Mobile and > Embedded newsgroups? Let us know! > https://www.windowsembeddedeval.com/community/newsgroups > > "Tim Johnson" <tjohnson@high-point.com> wrote in message > news:eyG%23x2VhEHA.1392@TK2MSFTNGP11.phx.gbl... > > I've read up on how to use P/Invoke to work with unmanaged legacy dlls > > with > > a flat API. But how do you do that for a legacy dll that is built as a > > set > > of classes? If I do a dumpbin of the dll I get decorated names which > > include the class name as well as the method name. But I can't determine > > from that the right syntax for the DllImport expression in my C# program. > > > > For example, for a dll that exports a class XXX with a constructor, > > destructor, and 1 method named Foo a normal C++ program could call things > > like this: > > > > XXX:XXX(); > > XXX:~XXX(); > > int XXX:Foo(int i); > > > > But how/what to invoke from C# with P/Invoke - what's the right signature > > for the DllImport attribute? > > -- > > Tim Johnson > > High Point Software > > www.high-point.com > > (503) 312-8625 > > > > > >
- Next message: Shrage H. Smilowitz: "Re: How can i load a csv file into a dataset in .Net Compact framework"
- Previous message: Peter Foot [MVP]: "Re: PInvoke a legacy class?"
- In reply to: Peter Foot [MVP]: "Re: PInvoke a legacy class?"
- Next in thread: Alex Feinman [MVP]: "Re: PInvoke a legacy class?"
- Reply: Alex Feinman [MVP]: "Re: PInvoke a legacy class?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|