I'm having trouble figuring out exactly how to reference managed c++ code that calls c# code from unmanaged c++ code. Let me throw out a few scenarios:
- I have my unmanaged code reference and call my managed code, my managed code's call to my c# code is commented out, builds and works just fine. I uncomment my c# code, I now get compiler errors saying my c# namespace doesn't exist.
- In my unmanaged code I comment out the reference and call to my managed code. My managed code calls my c# code. Builds and runs just fine... You get the picture from here.
Compiler error is C2653.
Here's what I'm doing:
Unmanaged c++ code: I've set the linker to include my managed c++ lib file.
#include "ManagedCpp.h"
ManagedCpp::foo();
Managed C++:
extern "C" __declspec(dllexport) void __stdcall foo()
{
CssCode::bar();
}
C#
public static void bar()
{
// From here it initializes some stuff from the registry
// into some data structures which I plan on marshaling
// back with other method calls, which I know involves placing
// things on the stack that can be returned normally to the
// managed c++ code which then will need to be marshed back to the
// unmanaged c++ code.
// All code will be static.
}
What am I doing wrong? As far as I can tell I need to hide my c# calls from the unmanaged code but I'm not quite sure how to do that.