These two titles in the docs might help.
"Accessing C++ Code from .NET Framework Objects"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/v
cmg_accessingcodefromframeworkobjects.asp
"Platform Invocation Services"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/v
cmg_PlatformInvocationServices.asp
Greetings! Thank you very much for some reply. I wonder if my question is
so obvious nobody cared to answer or if, theoretically, I was doing things
right and it should be working, so things are more complicated!
As said on the 2nd link,
>"Platform Invocation Services"
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/html/v
cmg_PlatformInvocationServices.asp
>,
>*An important and unique feature of Managed Extensions for C++ is that you
>can use unmanaged APIs directly. Data marshaling is handled automatically.
>If you do not require customized data marshaling, you do not need to use
>PInvoke. *
This is what I actually want to do. I'm using Managed Extensions for C++! My
Executable project is in C++, not on C#, Visual Basic or
any other language. Should the marshaling still be necessary?
*
>Advantages of IJW There is no need to write DLLImport attribute
>declarations for the unmanaged APIs the program uses. Just include the
>header file and link with the import library.
*
There, I've included the header file and included the .LIB file. Isn't that
what I am really supposed to do? Am I doing something wrong?
I checked the .DLL file with depends.exe and found out the decorated name
for the function is
'?MyMethod@CDrawDll@@QAEXXZ,
but the linker error mentions
"public: void __thiscall Project::CDrawDll::MyMethod(void)"
(?MyMethod@CDrawDll@Project@@$$FQAEXXZ)'
Could this @Project@ reference be the reason why it isn't resolving the
symbol? "Project" is the name I gave for the 'Windows Forms Executable"
project, that tries to use the DLL.
Thanks for any help!
Gustavo
Ian Lazarus - 06 Jan 2005 22:54 GMT
I'm in the same boat as you. I'm just beginning to learn C++ with extension,
and the first thing I tried is to call a C++ class which is located in a
DLL. I looked high and low and found no help in how to do so. That's
probably why one of those links limits itself to directly calling functions
in a DLL. I finally came to the conclusion that it is not possible, which is
probably why the other link suggested wrapping the C++ class, which is what
I am finally now doing. As an aside, in case it is helpful, my wrapping
class only exposes managed types, e.g., Int32, IntPointer, etc. I am
handling any necessary marshalling with my own code.