Let’s say I have a C++/CLI assembly compiled with the /clr switch. In that assembly, there are managed classes which call unmanaged (plain C++) classes defined in the same assembly. When you are debugging using Visual Studio, and you look at the call stack, it shows you where Managed->Unmanaged and Unmanaged->Managed transitions happen.
So, what caught my eye: Why is there no Managed/Unmanaged transition when one of the managed classes calls one of the unmanaged classes from the same assembly? Are those unmanaged classes somehow turned into managed classes behind the scenes?
Probably because you didn’t tell the compiler that you wanted the ‘unmanaged code’ to compile to machine code. With /clr in effect, all code gets compiled to IL. It has no trouble with standard C++ code, there are just a few language constructs that are not supported.
If you mixed the code in a source code file then you can use a #pragma to switch:
You’ll need this too if you #include any headers that contain unmanaged code declarations.