将C ++ / CLI转换为C# [英] Translate C++/CLI to C#
问题描述
我有一个中小型的项目,在C + + / CLI。我真的很讨厌C ++ / CLI的语法扩展,我更喜欢在C#中工作。有没有一个工具可以转换一个到另一个?体面的工作
I have a small to medium project that is in C++/CLI. I really hate the syntax extensions of C++/CLI and I would prefer to work in C#. Is there a tool that does a decent job of translating one to the other?
编辑:当我说Managed c ++之前,我显然是指c ++ / CLI
When I said Managed c++ before I apparently meant c++/CLI
推荐答案
如果C ++代码是纯被管理的,你只能将托管C ++代码(和C ++ / CLI代码) 。如果不是 - 即如果源中包含本机代码 - 工具(如.NET Reflector)将无法为您翻译代码。
You can only translate Managed C++ code (and C++/CLI code) to C# if the C++ code is pure managed. If it is not -- i.e. if there is native code included in the sources -- tools like .NET Reflector won't be able to translate the code for you.
如果你有混合的本地C ++代码,那么我建议尝试将本机代码移动到一个单独的DLL中,通过容易识别的存根函数替换您对DLL函数的调用,将项目编译为纯.NET库,然后使用.NET反编译成C#代码。然后你可以通过p调用对你的本地DLL的调用来替换对stub函数的调用。
If you do have native C++ code mixed in, then I'd recommend trying to move the native code into a separate DLL, replace your calls to DLL functions by easily identifiable stub functions, compile your project as a pure .NET library, then use .NET reflector to de-compile into C# code. Then you can replace the calls to the stub functions by p-invoke calls to your native DLL.
祝你好运!我为你感觉!
Good luck! I feel for you!
这篇关于将C ++ / CLI转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!