B
Bob Altman
Hi all,
I have an unmanaged DLL. The entry points in the DLL are declared via a
..def file (which is syntactically easier for me to deal with than the arcane
#pragma gibberish).
Now I want some of the functions in this DLL to interact with a managed DLL.
For performance reasons, I need to be absolutely certain where the
transitions are between unmanaged and managed code and vice versa. I've
stared long and hard at the MSDN documentation, but I haven't found a clear
description of this, so I figured I'd ask in this NG.
From what I've read, it looks like all I need to do is:
1. Add the /clr option to my project (Property Pages->Configuration
Properties->General, "Common Language Runtime Support" field)
2. Include "#using <mscorlib.dll>" after the precompiled header directive in
any files that contain functions that want to call into managed code. I
believe (but I'm not certain) that *only* these files will be compiled as
managed code (unless I fiddle with #pragma managed/unmanaged). Further, if
I include the name of a function defined in one of these files in the .def
file, an unmanaged entry point will be exported from the DLL. When that
entry point is called, the unmanaged caller will magically call into the
managed code.
3. I also need to make sure managed and unmanaged code use different
precompiled header files, or disable precompiled headers alltogether.
Is this all correct?
I have an unmanaged DLL. The entry points in the DLL are declared via a
..def file (which is syntactically easier for me to deal with than the arcane
#pragma gibberish).
Now I want some of the functions in this DLL to interact with a managed DLL.
For performance reasons, I need to be absolutely certain where the
transitions are between unmanaged and managed code and vice versa. I've
stared long and hard at the MSDN documentation, but I haven't found a clear
description of this, so I figured I'd ask in this NG.
From what I've read, it looks like all I need to do is:
1. Add the /clr option to my project (Property Pages->Configuration
Properties->General, "Common Language Runtime Support" field)
2. Include "#using <mscorlib.dll>" after the precompiled header directive in
any files that contain functions that want to call into managed code. I
believe (but I'm not certain) that *only* these files will be compiled as
managed code (unless I fiddle with #pragma managed/unmanaged). Further, if
I include the name of a function defined in one of these files in the .def
file, an unmanaged entry point will be exported from the DLL. When that
entry point is called, the unmanaged caller will magically call into the
managed code.
3. I also need to make sure managed and unmanaged code use different
precompiled header files, or disable precompiled headers alltogether.
Is this all correct?