The easiest way to do this is to show the C # DLL as a COM object, and then create an instance from your C / C ++ application. See MSDN for a walkthrough.
Alternatively, if this is actually a C ++ application that you want to call the C # DLL with, you can create a mixed C ++ / CLI application that contains both managed and unmanaged code. A C ++ application can then call functions directly from a managed C # DLL.
Also see "Overview of Managed / Unmanaged Code Compatibility" on MSDN.
EDIT: Without more information than โit doesn't work in Cโ, I donโt even know which of the above suggestions you tried. As I suggested, I'm not sure that the second will work with direct C (never tried), but I see no reason why the first will not.
Regardless, a quick and dirty fix may be to wrap the C # functions in a C ++ DLL, which you then call from your C application. Make sure you declare any of the functions you want to export from C ++ DLL, like extern , otherwise their names will be distorted with C ++ names that cannot be operated with C. See here for more information: http://www.parashift.com/c++-faq-lite/mixing- c-and-cpp.html
source share