Click here to Skip to main content
13,000,022 members (48,264 online)
Rate this:
Please Sign up or sign in to 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 8-May-13 5:27am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^],[^],[^].


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100