I have an off the shelf product which supports custom plugins which need to be written in Unmanaged C. It doesn't support Managed Dll's and my language of preference is c#.
The information which needs to be passed back to the off the shelf product is very basic and can be held in a string.
So I was thinking I could do the following:
Now communicating between a Managed C++ and C# Dll is easy.
But I cant figure out how to call a managed c++ function from an unmanaged c dll. Any help with some simple sample code would be great.
Thanks
EDIT: I created a Code Project article on how I did this with Alex's answer below. http://www.codeproject.com/Tips/695387/Calling-Csharp-NET-methods-from-unmanaged-code
You almost got it right. Just put numbers 2 and 3 in the same C++/CLI DLL. You can both use .NET classes and export C functions from a C++/CLI project.
extern "C" __declspec( dllexport ) void __stdcall PureExportC(
const wchar_t* param
)
{
CSharpAssemblyNamespace::CSharpWorker worker;
worker.DoWork( gcnew String(param) );
}