Click here to Skip to main content
15,867,330 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
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
Comments
Sergey Alexandrovich Kryukov 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.
--SA

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

BTW I meant "use" not "sure".
Nish Nishant 27-Apr-11 16:39pm    
Corrected again (this time to "use")!
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
 
Share this answer
 
Comments
Nish Nishant 27-Apr-11 15:24pm    
Good response, voted 5.
Espen Harlinn 27-Apr-11 15:31pm    
Thank you, Nishant :)
Sergey Alexandrovich Kryukov 27-Apr-11 20:25pm    
Very interesting way, my 5.
--SA
Sandeep Mewara 28-Apr-11 0:49am    
My 5! Good to know.
SKOTAJI 28-Apr-11 5:21am    
Thank you. I will have to look at Xming. I will try this new way.
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.
 
Share this answer
 
Comments
Espen Harlinn 27-Apr-11 15:09pm    
Good reply, my 5
Sergey Alexandrovich Kryukov 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.
--SA
SKOTAJI 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900