473,662 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using legacy C/C++ code with C#

I have legacy code I wrote in C (and some C++). What is the recommended
way to use my legacy code from C# ?
Jun 27 '08 #1
2 1276
On Thu, 12 Jun 2008 17:14:24 -0700, Bit Byte <ro**@yourbox.c omwrote:
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
Jun 27 '08 #2
"Peter Duniho" <Np*********@nn owslpianmk.comw rote in
news:op******** *******@petes-computer.local:
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.
My C++ code needs to remain as portable code for other platforms, so I took
the latter route, wrapping it in C++/CLI (the name adopted for managed
C++). Check out the sister newsgroup
"microsoft.publ ic.dotnet.langu ages.vc" for help with that language.
Jun 27 '08 #3

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

Similar topics

4
2078
by: JellBell | last post by:
I dont know what is a legacy system..please help me out Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com
4
1410
by: Mark | last post by:
In the Visual C++ 7.1 compiler is there a legacy code mode? This is for non-GUI code. Its easy enough to bring the project in but of course I get a lot of clashes with ISO std C++ conventions. example) old style std library includes such as iostream.h thanks
3
1764
by: masood.iqbal | last post by:
In this day and age, you never say no to any work that is thrown at you ---- so when I was offered this short-term contract to convert legacy C code to C++, I did not say no. Personally I believed that it was a somewhat futile exercise since one of the main requirements was for the existing API (a functional interface written in C) to remain the same. I would have much rathered that the mandate be ab-initio, but that was not the case...
19
4815
by: Mark Miller | last post by:
QUESTION: Does anyone know how I can use v2.6 of the MSXML parser with .NET? BACKGROUND: I "Web to Print" process that allows our clients (newspapers) to export their data and pass it thru a custom Xslt stylesheet we have created for their print system. The idea of the whole process for them is they request the export and then they get a text file they can import (copy / paste) into their system with all their styles and layout...
2
1634
by: Mark Olbert | last post by:
First off, the sympathy is for all you poor buggers out there who have to figure out how to marry Managed Extensions for C++ onto your legacy code. My condolences; my brief experience with the process leads me to believe the Microsoft hates all of its VC++ developers :) Now, the question. I'm getting a NullReferenceException in a __gc class that wraps functionality in a legacy C/C++ app (it's actually part of the Nero burning rom api). ...
2
1152
by: DocAccolade | last post by:
I am trying to include a legacy com control (controlname.ocx) in an asp.net application using vs 2003. I have added the control to the user control tool box, then dragged it to the form. However, when i try to reference it in code, it does not seem to exist. I declared the object variable and the ide reports the class members. The intellisense then recognizes the child members of the object variable and provides them in a drop down,...
4
11187
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. What I would like to do is make the serial port accessible via a web service. The web service and the legacy application would be running on the same machine. The mobile application would access the web service via a network connection. It...
30
4097
by: Pep | last post by:
Is it best to include the code "using namespace std;" in the source or should each keyword in the std namespace be qualified by the namespace tag, such as std::cout << "using std namespace" << std::endl; Myself I am not sure which I prefer, it is certainly easier to specify that the std namespace is being used instead of tagging each member of the namespace?
4
1602
by: Jason Madison | last post by:
I would like to create a .net application that still uses a few screens from an old legacy application we have. I can list records from the database in my .net app, but when it comes to making updates I still need to legacy screens as the update logic is very complex. I have found I can use SetParent to "embed" some of the legacy screens within my .net app, but because they are still basically two separate applications clicking...
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.