Click here to Skip to main content
13,045,248 members (49,268 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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 12-Mar-13 23:22pm

1 solution

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

Solution 1

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.
AYDIN EBRAHIMI 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 EBRAHIMI 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 EBRAHIMI 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 13 Mar 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