Re: Using legacy C/C++ code with C#



On Thu, 12 Jun 2008 17:14:24 -0700, Bit Byte <root@xxxxxxxxxxx> wrote:

I have legacy code I wrote in C (and some C++). What is the recommended way to use my legacy code from C# ?

It really depends on the code. IMHO, the best way is to just port it and abandon the original. :)

But sometimes you'd prefer to stick with the original (for example, it's still used elsewhere and you only want to maintain one code base).

In that case, your two main options are to compile it to a DLL and use p/invoke, or wrap the code in managed C++ and produce a managed DLL directly usable from C#. The latter is basically the same as the former, but more explicit. In other words, it could be more work, but you have more control over the resulting interface too.

Pete
.



Relevant Pages

  • Re: COMM Control
    ... On further investigation the comm control does work, when the port is open ... to stop support, but there most be an awful lot of legacy code out there. ...
    (microsoft.public.windowsce.embedded.vb)
  • fscanf for streamed I/O
    ... I am in the process of porting some legacy code to vxworks and am ... running into problems with reading from the port. ...
    (comp.os.vxworks)
  • Re: throttle ssh logins (OpenSSH sshd)
    ... A more extreme option is to abandon the well-known port and use a ... different port number. ... considered to be a security solution. ...
    (comp.security.ssh)
  • Re: Direct instantiation and configuration
    ... Von Rick Jackson: ... > directly-instantiated component. ... I have some legacy code which looks ... > port map; ...
    (comp.lang.vhdl)
  • Re: throttle ssh logins (OpenSSH sshd)
    ... |> different port number. ... |> considered to be a security solution. ... some libraries would be more of an issue. ...
    (comp.security.ssh)