Click to See Complete Forum and Search --> : unmanaged to managed code conversion


lpr
October 25th, 2004, 04:56 AM
I have an unmanaged DLL,I want to convert this to a Managed code so that C# and VB can access the resulting managed DLL, we decided to use Managed Extensions for C++(MC++)
As i am facing difficulties in analyzing the concepts hidden with in MC++,i want to know as
1.how to take the existing unmanaged code and compile it to managed code, (with the /clr
compiler switch and It Just Works (IJW) )
2.Also to write managed wrappers around unmanaged functions.

I think this may be a way, but absolutely don't know whether it is right or wrong??
To create a blank solution in Visual Studio and add the following projects
1) Unmanaged (old dll)
2) Managed (dll written using MC++)
3) and finally the C# project which accesses this Managed project
If this is correct, then is it possible for me to
1) directly take my old MFC DLL and open it in Visual Studio
2) should i add the .cpp and .h files from old dll to the managed project
3) should the import library of old dll be added to linker dependancies in the
managed project
if all the above mentioned steps are wrong then would any body please tell what are the detailed steps i am supposed to follow

thanks in advance
lpr

atkin
October 25th, 2004, 05:31 AM
Hi
Last week i was faced with the same task as you and this morning I have completed it.
What i did was read the folllowing:

http://www.codeguru.com/columns/Kate/

Read everthing on HeadSpinning, this should give you a pretty good knowledge. You certainly have more of a head start than i did when i started.
I think all your steps are correct. Since you have the source code it should be simpler.
You need to use dllexport so that you managed wrapper can see the funtions that you utilize.