Help!!!
I am new to c# (.NET) and I am attempting to create a DLL plugin for an older windows program (i.e not .NET framework), it requires only one function "UserInstruction" it needs to access to be in the DLL.
How can I make this DLL into one that this program can use? Currently it sees the DLL but does not recognise the function within the DLL.
Any thoughts, opinions, tutorials, articles, lessons (not entirely clued up on the DLL differences) would be very much appreciated.
AlanPosted Oct 7, 2008, 4:04 PM
Yes, creating a 'mixed mode' Visual C++ dll is probably your best option here.
However, there is a little known technique which does allow static functions in a C# dll to be called from unmanaged C++. This technique doesn't use COM interop but inverse P/Invoke.
Basically, you need to create an unmanaged export table in the C# dll which enables the C++ code to call these functions as if they were being exported from a C dll. The problem is that this technique isn't directly supported in C#. You have to use ilasm.exe to change the IL directly and then recompile the dll.
The steps that need to be taken are explained in detail in the following article:
http://www.csharphelp.com/archives3/archive500.html
Although this article was written with a view to calling C# functions from a language called Blitz3D, it works with any unmanaged language that can consume C dlls including, of course, C++.
Daniel Innala AhlmarkPosted Oct 7, 2008, 1:03 PM
Using unmanaged DLLs from a managed .NET environment (like from C#) is not a difficult task.
You're trying to accomplish the reverse thing: using a DLL compiled for .NET from an unmanaged application. This I don't think is possible. I don't think you can compile "native code" DLLs with C#, although I do believe you can do so with C++.NET.
Regards,
Daniel