Click here to Skip to main content
11,805,316 members (63,830 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C++ C# Architect
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.
Posted 27-Apr-11 8:02am
SAKryukov at 27-Apr-11 20:34pm
I vote 5 for the question; resolution will be labor taking and maybe painful, but the problem itself is practically actual.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Espen Harlinn at 27-Apr-11 15:09pm
Good points, my 5 :)
Nishant Sivakumar at 27-Apr-11 15:10pm
Thank you, Espen!
Manfred R. Bihy at 27-Apr-11 16:32pm
No need to sue anybody Nish!
I agree with the rest though. 5+
Nishant Sivakumar at 27-Apr-11 16:34pm
LOL :-)

BTW I meant "use" not "sure".
Nishant Sivakumar at 27-Apr-11 16:39pm
Corrected again (this time to "use")!
SAKryukov at 27-Apr-11 20:33pm
Agree with all of this, my 5.
The Motif is the issue. If the UI was done at the level of GTK+, and/or Gnome API or Qt, it would be much better -- there is a .NET and/or Mono support for those libraries. I never heard Motif is supported anywhere for managed platform. (Probably Motif is somewhat outdated?).

SKOTAJI at 28-Apr-11 5:10am
Thanks for sharing your valuable solution. As said Nishant, i would like to proceed with a wrapper class on top of C++ application using a buffer exchange or any message queuing. Now i will not work on to port the code into managed C++ and to C#. I will proceed with C# UI and middle layer as C++. Hope this is good. Thank you.
Nishant Sivakumar at 28-Apr-11 8:06am
You are welcome.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Depending on the complexity of your project, you might want to take a look at:

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.

Espen Harlinn
Nishant Sivakumar at 27-Apr-11 15:24pm
Good response, voted 5.
Espen Harlinn at 27-Apr-11 15:31pm
Thank you, Nishant :)
SAKryukov at 27-Apr-11 20:25pm
Very interesting way, my 5.
Sandeep Mewara at 28-Apr-11 0:49am
My 5! Good to know.
SKOTAJI at 28-Apr-11 5:21am
Thank you. I will have to look at Xming. I will try this new way.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Espen Harlinn at 27-Apr-11 15:09pm
Good reply, my 5
SAKryukov at 27-Apr-11 20:29pm
This is right idea, but I wish you would just mention replacement or re-using Motif-based part, which is can be a major problem. Also, COM is the worst case in my opinion. If OP is good at C++, C++/CLI would be relatively easy to master, best option overall. I voted 4.
SKOTAJI at 28-Apr-11 5:32am
Thanks for sharing your valuable solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 3,265
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 27 Apr 2011
Copyright © CodeProject, 1999-2015
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