Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a really big project from MFC/C++ VS2002 and I need to the develop,new features from C#-with .Net4. so I have know can I add another project with C# language and .Net4 from my MFC project and develop new features and link each other with DLL ?

tnx a lot;)
Posted

1 solution

Yes, you can do it. I've been through the same process. Here is what I recommend...

VS2002 is the oldest version of .NET - first update your C++ code to something more recent (ie. VS2012/VS2012). When upgrading, you will probably find that the newer compiler versions find more coding errors and indiscretions. Fix all of these and make sure that everything works as expected. While you are changing/upgrading your source, I also recommend /W4 warning level, which will enhance the compiler help. I went through this process on a 10 million line code base and was astounded at the garbage in the source which somehow magically worked. This is your best opportunity to fix these types of errors.

After you have completed this part of the process (and not before!), change your project executable to enable C++/CLI. Read up on mixed mode execution. You will now be able to create new managed DLLs that you can call from the executable.

What I have described is how to call managed code from project.exe. Managed code can call unmanaged DLLs via several mechanisms (see "P/Invoke", ...). Calling managed code from unmanaged DLLs is much more complicated. You will also be limited to MFC UI features. Different Visual Studio versions give you different capabilities.
 
Share this answer
 
Comments
Aydin Homay 13-Mar-13 16:43pm    
Dear Brydon

My project to the from of MFC not .net
H.Brydon 13-Mar-13 17:00pm    
Right. Your project is currently MFC (unmanaged). You can make it MFC (managed). It will become a C++/CLI application. Your MFC executable can call C# code. Unmanaged DLLs will take more work (you will need to research more but it can be done).
Aydin Homay 13-Mar-13 17:08pm    
Dear Brydon

Do you have any link or reference about it,
H.Brydon 13-Mar-13 17:10pm    
Well ... the instructions in my answer above are pretty straightforward and not difficult. Everything else is pretty much in the documentation where you expect it.
Aydin Homay 16-Mar-13 11:20am    
Thank you for your answer I do it and I went through this process on 7 million line code in MFC(unmanaged) to MFC(managed) from Visual Studio 2010 and I want convert to the C++ 2010 .net 4 right now. ;)

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