使用C ++代码开发C#项目 [英] Developing a C# project using C++ code

查看:86
本文介绍了使用C ++代码开发C#项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在这里查询.请为我将来的项目使用情况进行说明.

我有一个基于X-Motif的C ++项目.现在,我的客户希望以其他目的重用C ++项目.是否有可能将所有代码移植/将代码重用到C#中?如果可能的话,可以使用WPF ...

请给我一些想法,以重用以前的功能.

寻找您的宝贵答案.

谢谢与问候,
KV Subrahmanyam.

Hello all,

I a query here. Please explain for my future projects usage.

I have a C++ project which is built on X-Motif. Now my customer wants to reuse the C++ project in some other purpose. Is there any possibility to port all the code / reuse the code into C# ? If possible is it ok with WPF ...

Please give the ideas to me to reuse the previous functionality.

Looking for your valuable answers.

Thanks & Regards,
KV Subrahmanyam.

推荐答案

好吧,您可以使用C ++/CLI来包装很多内容,但是我可以告诉您,它不会使您免于重写大部分内容您的UI代码. WPF是与X完全不同的UI框架.因此,您可能会重写99%的UI内容.减少重写的一种方法是下载并使用Windows的X服务器,即使这样,可能也需要进行一些重写和重新设计,但这并不会花费太多的工作.
Well you can use C++/CLI to wrap a lot of it, but I can tell you that it won''t save you from rewriting most of your UI code. WPF is a completely different UI framework from X. So you''d probably rewrite 99% of your UI stuff. One way to reduce rewrite would be to download and use an X server for Windows, and even with that there may be some rewrite and redesign needed, but it won''t be too much work.


取决于项目的复杂性,您可能需要看一下:
Xming [ ^ ]

WeirdX [ ^ ]

第一个选项可以让您按原样重用代码.如果您的代码是面向* nix的,则可能需要查看 Windows Services for UNIX(SFU) [ ^ ],并将其与Xming结合使用.

WeirdX是X的Java实现-虽然将其移植到c#和WPF会比较苛刻,但它应该为您提供有关如何执行此操作的想法.

问候
Espen Harlinn
Depending on the complexity of your project, you might want to take a look at:
Xming[^]
or
WeirdX[^]

The first option could allow you to resuse your code as is. If your code is very *nix oriented you may want to take a look at Windows Services for UNIX (SFU)[^], and use this in conjunction with Xming.

WeirdX is a java implementation of X - while porting this to c# and WPF will be relatively demanding, it should give you an idea about how to do this.

Regards
Espen Harlinn


您应该查看 C ++/CLI .
我认为这将在很大程度上起作用.

这使得可以使用C ++中的.Net代码.
要使用.Net中的C ++代码,您将需要使用C ++/CLI编译器重新编译它,
大部分代码都可以重新编译而没有任何问题.
您可能需要添加一些转换/互操作,以便在本机和托管对象之间进行翻译.
如果有一些代码,则无法重新编译.您可以添加一个用C ++/CLI编写的Interop DLL,它包装了本机代码.

另一种选择是使您的C ++代码成为COM DLL.

您应该考虑将GUI与实现分开.
那可能会增加您成功的机会.
You should look into C++/CLI.
I think that will work to a high degree.

It makes it possible to use .Net code from C++.
To use C++ code from .Net, you will need to recompile it with the C++/CLI compiler,
Most of the code , recompiles without any problems.
You will probably need to add some conversion/interop for translating between native and managed objects.
If some code, cannot be recompiled. You can add an Interop DLL written in C++/CLI, which wraps the native code.

Another option is to make COM DLLs of your C++ code.

You should consider separating the GUI from the implementation.
That will probably increase your chances of success.


这篇关于使用C ++代码开发C#项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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