Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# Unmanaged Managed
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 6:27am

1 solution

Rate this: bad
good
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:
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
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 495
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 200
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 8 May 2013
Copyright © CodeProject, 1999-2014
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