473,387 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

C# to C++ port

Hi everyone,

We have a dll component developed in C# and used by the other projects (exe)
written in C#.
This component has been tested and proved to be very robust component and so
we are going to re-use it in another application (very large code base)
which has been already written in unmanaged C++.
What is the best strategy between the following two options:

1. Write a managed C++ wrapper around the C# component and use that wrapper
in our unmanaged C++ project.

2. Port the C# component completely to an unmanaged C++ component and then
use it in our unmanaged C++ project.
The main advantage of option 1 is that it seems much quicker and we can also
benefit from .Net framework library without having to re invent the wheel or
use other 3rd party libraries.

The main advantage of option 2 is that we are not going to get involved in
the potential problems involved in mixing managed and unmanaged codes.

Does anyone have any other ideas (maybe option 3 ...) or see another pros
and cons in going with either option 1 or option 2?

Any help would be appreciated

Luca.
Oct 18 '06 #1
6 2042
hi,

You are clear of the pro and con of both solutions, it's up to you or your
group to valorate the best way to go depending of your resources, skills and
complexity of both pieces of code
--
Ignacio Machin
machin AT laceupsolutions.com
"Luca" <no****@nojunk.comwrote in message
news:eh**********@news-01.bur.connect.com.au...
Hi everyone,

We have a dll component developed in C# and used by the other projects
(exe) written in C#.
This component has been tested and proved to be very robust component and
so we are going to re-use it in another application (very large code base)
which has been already written in unmanaged C++.
What is the best strategy between the following two options:

1. Write a managed C++ wrapper around the C# component and use that
wrapper in our unmanaged C++ project.

2. Port the C# component completely to an unmanaged C++ component and then
use it in our unmanaged C++ project.
The main advantage of option 1 is that it seems much quicker and we can
also benefit from .Net framework library without having to re invent the
wheel or use other 3rd party libraries.

The main advantage of option 2 is that we are not going to get involved in
the potential problems involved in mixing managed and unmanaged codes.

Does anyone have any other ideas (maybe option 3 ...) or see another pros
and cons in going with either option 1 or option 2?

Any help would be appreciated

Luca.


Oct 18 '06 #2
Given that you have tested and proved robustness of the C# code, I'd write a
wrapper around it. Going with option 2 will involve a lot of testing that
you have already done.

Mike Ober.

"Luca" <no****@nojunk.comwrote in message
news:eh**********@news-01.bur.connect.com.au...
Hi everyone,

We have a dll component developed in C# and used by the other projects
(exe) written in C#.
This component has been tested and proved to be very robust component and
so we are going to re-use it in another application (very large code base)
which has been already written in unmanaged C++.
What is the best strategy between the following two options:

1. Write a managed C++ wrapper around the C# component and use that
wrapper in our unmanaged C++ project.

2. Port the C# component completely to an unmanaged C++ component and then
use it in our unmanaged C++ project.
The main advantage of option 1 is that it seems much quicker and we can
also benefit from .Net framework library without having to re invent the
wheel or use other 3rd party libraries.

The main advantage of option 2 is that we are not going to get involved in
the potential problems involved in mixing managed and unmanaged codes.

Does anyone have any other ideas (maybe option 3 ...) or see another pros
and cons in going with either option 1 or option 2?

Any help would be appreciated

Luca.


Oct 18 '06 #3
I agree with Michael. Use the C# dll via interop. Your chances of
hitting errors are much smaller.

Oct 18 '06 #4

"Michael D. Ober" <obermd.@.alum.mit.edu.nospamwrote in message
news:uI**************@TK2MSFTNGP05.phx.gbl...
Given that you have tested and proved robustness of the C# code, I'd write
a wrapper around it. Going with option 2 will involve a lot of testing
that you have already done.
Additional advantages of making a C++ version are -- no runtime dependency
on .NET Framework, reduced memory footprint, portablity.

Also, if you have a lot of good unit tests for the C# version they will help
a lot with porting.

Even so, unless you are badly constrained for memory or disk space, or need
cross-platform capability, I agree with wrapping the working C# component.
>
Mike Ober.

"Luca" <no****@nojunk.comwrote in message
news:eh**********@news-01.bur.connect.com.au...
>Hi everyone,

We have a dll component developed in C# and used by the other projects
(exe) written in C#.
This component has been tested and proved to be very robust component and
so we are going to re-use it in another application (very large code
base) which has been already written in unmanaged C++.
What is the best strategy between the following two options:

1. Write a managed C++ wrapper around the C# component and use that
wrapper in our unmanaged C++ project.

2. Port the C# component completely to an unmanaged C++ component and
then use it in our unmanaged C++ project.
The main advantage of option 1 is that it seems much quicker and we can
also benefit from .Net framework library without having to re invent the
wheel or use other 3rd party libraries.

The main advantage of option 2 is that we are not going to get involved
in the potential problems involved in mixing managed and unmanaged codes.

Does anyone have any other ideas (maybe option 3 ...) or see another pros
and cons in going with either option 1 or option 2?

Any help would be appreciated

Luca.



Oct 18 '06 #5
If we go with option 2 do you see any issues on performance?
i.e. does the final unmanaged C++ application runs slower if we use wrapper
around C# code compare to when it calls native C++ code?

Also any issue about mixing managed and un managed code (memory management)?
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Michael D. Ober" <obermd.@.alum.mit.edu.nospamwrote in message
news:uI**************@TK2MSFTNGP05.phx.gbl...
>Given that you have tested and proved robustness of the C# code, I'd
write a wrapper around it. Going with option 2 will involve a lot of
testing that you have already done.

Additional advantages of making a C++ version are -- no runtime dependency
on .NET Framework, reduced memory footprint, portablity.

Also, if you have a lot of good unit tests for the C# version they will
help a lot with porting.

Even so, unless you are badly constrained for memory or disk space, or
need cross-platform capability, I agree with wrapping the working C#
component.
>>
Mike Ober.

"Luca" <no****@nojunk.comwrote in message
news:eh**********@news-01.bur.connect.com.au...
>>Hi everyone,

We have a dll component developed in C# and used by the other projects
(exe) written in C#.
This component has been tested and proved to be very robust component
and so we are going to re-use it in another application (very large code
base) which has been already written in unmanaged C++.
What is the best strategy between the following two options:

1. Write a managed C++ wrapper around the C# component and use that
wrapper in our unmanaged C++ project.

2. Port the C# component completely to an unmanaged C++ component and
then use it in our unmanaged C++ project.
The main advantage of option 1 is that it seems much quicker and we can
also benefit from .Net framework library without having to re invent the
wheel or use other 3rd party libraries.

The main advantage of option 2 is that we are not going to get involved
in the potential problems involved in mixing managed and unmanaged
codes.

Does anyone have any other ideas (maybe option 3 ...) or see another
pros and cons in going with either option 1 or option 2?

Any help would be appreciated

Luca.




Oct 18 '06 #6
"Luca" <no****@nojunk.comwrote in message
news:eh**********@news-01.bur.connect.com.au...
If we go with option 2 do you see any issues on performance?
i.e. does the final unmanaged C++ application runs slower if we use
wrapper around C# code compare to when it calls native C++ code?
I think you meant option 1 - wrap the C# dll in an unmanaged wrapper.

Parts of it will no doubt run slower, other parts may run faster. There's
an unavoidable penalty to pay when the process first loads the CLR and JIT
compiles the classes you're using. Once that's out of the way, you probably
wouldn't see much difference, but that depends a great deal on exactly what
the wrapped code actually does. Using the wrapping technique, the memory
footprint of the resulting app will no doubt be larger - several megabytes
larger. That could lead to performance issues related to paging if the
machine it's running on is highly memory constrained.

In short, the scenarios under which the wrapping solution gives better
performance are few and far between. The scenarios under which is gives
acceptable (if slightly slower) performance are far more numerous.
>
Also any issue about mixing managed and un managed code (memory
management)?
Sure. Don't try to delete manged memory, and don't leak unmanaged memory.
As long as you keep the two straight, the two systems can coexist
peacefully.

-cd
Oct 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Alexander N. Spitzer | last post by:
If I have a machine with 3 virtual IP addresses (192.168.1.), how can I start 3 instances of the same RMI application (each started with different properties/configs), each listening on the port...
0
by: per.bergstrom | last post by:
To whom it may concern, The serial port server 'cnhd38' has been terminated (on who's initiative, I don't know). It affects the users of the (at least) following nodes: cnhd36, cnhd44, cnhd45,...
2
by: willie | last post by:
Hi, I'm writing a program which requires the use of three serial ports and one parallel port. My application has a scanning devices on each port, which I can access fine with pyserial. ...
5
by: Jason | last post by:
After a server accepts a client connection on a certain port, a new socket is created on the server on a system managed dynamic port to handle the connection. Please confirm this. If so, how...
6
by: kai | last post by:
Hi, I was tring to run an example (HelloWorld.aspx) from MSPrss book, I get this message: "ASP.NET Development Server faild to start listening port 1034. Error message: An attempt was made...
7
by: Sharon | last post by:
Hi all, I've implemented a TCP server using the Socket async methods. When connecting to the server from 3 instances of hyper terminal, i've noticed that each of the newly created server sockets,...
4
by: H J van Rooyen | last post by:
Hi All, I am writing a polling controller for an RS-485 line that has several addressable devices connected. It is a small access control system. All is well- the code runs for anything from...
25
by: bmearns | last post by:
Is it possible to specify which port to use as the outbound port on a connection? I have the IP address and port number for the computer I'm trying to connect to (not listening for), but it's...
13
by: Rob | last post by:
Hi all, I am fairly new to python, but not programming and embedded. I am having an issue which I believe is related to the hardware, triggered by the software read I am doing in pySerial. I...
5
by: Maciej Sondej | last post by:
Hi, I have problem. I want to react on event which come from IO.Port(RS232). I have a class that works on console application class Program { static void Main(string args) {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.