Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
I am trying to go the opposite way of most articles I have found. I need to create an unmanaged, C++ DLL to serve as an entry into a C# DLL. The reason is that I need to expose functions to Firebird/Interbase as UDFs. I do not know C++ and am looking for assistance in creating a simple wrapper for my managed code. My C# DLL has one function (at the moments) called SOUNDEX that accepts a single varchar(50) string and returns a char(4) variable.
Posted

1 solution

You can do it by using C++/CLI and mixed-mode (managed+unmanaged) project. You can really use "regular" C++ classes with C++/CLI "ref" classes. You can really wrap a "regular" C++ class or struct around some "ref" types used in the implementation of the wrapper class.

Everything else depends on your problem.

Note that exporting of some .NET assembly methods as unmanaged is considered impossible, but this is not true, as such possibility is standardized in the CIL. There are know techniques for doing this without C++/CLI, by disassembling of the assembly compiled into CIL into IL, modification of the code and compiling it back. Please see the references (all to the CodeProject articles, by the way) in my past answers:
loading C# DLL in MFC[^],
How can I use a dll created in Visual Basic 2008 in Visual Basic 6.0[^],
Call Managed DLL written in C# from Unmanged Code VC++[^],
API's in .Net: Managed or UnManaged Code[^].

As you could see, this approach is legitimate, but not very straightforward, so C++/CLI approach has apparent benefits. Please see also:
http://en.wikipedia.org/wiki/C%2B%2B/CLI[^],
http://www.ecma-international.org/publications/standards/Ecma-372.htm[^],
http://msdn.microsoft.com/en-us/library/xey702bw.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900