Export managed DLL to un-managed program

Feb 21 2005 3:58 PM
Hi, Want to find out if there is anyone managed to be able to code and DLL in managed code (C#/Managed C++) and have that DLL loaded into a native program. I found a lot info on how to invoke native.dll into managed environment and I was able to that. I need to do the reverse, i.e., implement an DLL in managed code and then export it to standard native program. We are planning to move to “.NET” but still need to support the older platform that are coded in native code. Also we don’t want to go with COM for a lot of other reasons, period. I did some Google search and saw some sample codes on explaining how to ix managed and un-managed code inside MS VC++.NET. Like the following code segment. #include "stdafx.h" #define EXPORT(a,b) __declspec(dllexport) a b #define DllEntryPoint DllMain #include "tcl.h" #using using namespace System; using namespace ManagedAssembly; #include "stdio.h" void ManagedFunction() { printf("Hello, I'm managed in this section\n"); ConsoleCmdProc *cmd = new ConsoleCmdProc(); cmd->Hello(); } #pragma unmanaged void UnmanagedFunction() { printf("Hello, I am unmanaged through the wonder of IJW!\n"); ManagedFunction(); } EXTERN int Umanaged_Init (Tcl_Interp *interp); EXPORT(int,Umanaged_Init) (Tcl_Interp *interp) { UnmanagedFunction (); return 0; } But when it is loaded into the native program, like tclsh84.exe, it crashed the tclsh… It crashed at UnmanagedFunction->printf("Hello, I am unmanaged through the wonder of IJW!... So, any help will be helpful.