使用MFC和C#.net 4从visual studio 2002开发项目 [英] Developing Project From visual studio 2002 with MFC and C# .net 4

查看:63
本文介绍了使用MFC和C#.net 4从visual studio 2002开发项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我有一个非常大的项目来自MFC / C ++ VS2002,我需要开发C#带有.Net4的新功能。所以我知道我可以从我的MFC项目中添加C#语言和.Net4的另一个项目并开发新功能并使用DLL相互链接吗?



tnx很多;)

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;)

推荐答案

是的,你可以做到。我经历过同样的过程。这是我推荐的......



VS2002是最早的.NET版本 - 首先将您的C ++代码更新为更新的版本(即VS2012 / VS2012)。升级时,您可能会发现较新的编译器版本会发现更多的编码错误和疏忽。修复所有这些并确保一切按预期工作。在您更改/升级源代码时,我还建议使用/ W4警告级别,这将增强编译器的帮助。我在1000万行代码库上完成了这个过程,并对源代码中的垃圾感到惊讶,这些垃圾在某种程度上神奇地起作用。这是修复这些类型错误的最佳机会。



完成此部分过程后(而不是之前!),更改项目可执行文件以启用C ++ / CLI。阅读混合模式执行。您现在可以创建可以从可执行文件中调用的新托管DLL。



我所描述的是如何从project.exe调用托管代码。托管代码可以通过多种机制调用非托管DLL(请参阅P / Invoke,...)。从非托管DLL调用托管代码要复杂得多。您还将仅限于MFC UI功能。不同的Visual Studio版本为您提供了不同的功能。
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.


这篇关于使用MFC和C#.net 4从visual studio 2002开发项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆