I have to write a dll that can be used by a legacy app. The legacy app looks
for a set of specific exported functions, with mangled names (in the form
_MyMangledFunction@nn). I really don't want (or need, or am able without
spending a lot of time) to write the whole thing in C.
It is my intention to provide the appropriate exports from a (MFC, or just
win32) C++ wrapper dll and from there pass everything straight through to
equivalent functions in a managed class in a managed DLL (VB or C#) which
will handle the logic.
1. I have written a test host app to emulate the legacy app that can call
_MyMangledGetNumber@0() in TestMFCDLL.dll
2. I have written a TestMFCDLL.dll in C++ (mix managed/unmanaged) that
exports MyMangledGetNumber() and returns a number to the test app.
3. I have written a TestVBDLL.dll class library defining a class called
MyManagedClass with a method GetNumber() that contains the logic I need.
The flow is this:
in host app (somewhere)
myIntegerVar = _MyMangledGetNumber@0() //from TestMFCDLL.dll
in TestMFCDLL.dll:
DWORD WINAPI MyMangledGetNumber()
{ //HOW DO I create an instance of TestVBDLL.MyManagedClass
//call to MyManagedClass.GetNumber() where logic resides
return MyManagedClass.GetNumber();
}
What I don't know how to do is the commented elements above. (The actual
scenario is - obviously - more complex than this, but this example
illustrates the essence of the problem). I am able to mix managed and
unmanaged code in TestMFCDLL.dll (safely), and am aware about ensuring it is
/NOENTRY etc.
Is this even a reasonable approach? Or can I create an appropriate .dll in
any dotnet language and export suitably mangled names some other way? I'm
looking, I suppose for both the quick, syntactic solution and broader views.