473,763 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using C++ in C#, best suggestion in this situation?

I thought I would post here, as I am sure someone, somewhere has run into
this problem, and might have a good solution for me.

I am writing an applicaiton in C# that will accept data and then put it into
an Excel spreadsheet. Easy, right? Well it is, until you have to get the
data from another application that is written in Borland C++ PowerBuilder 5.

The situation is that the Borland Code isnt going to get re-written (too
expensive, couple million lines of code) so we have to develop in Borland
still to handle some things, and the ACE is being used for ease of
communication between compilers (it is basically platform independent).
Unfortunately, the ACE code is not written in C#, but in C++. So, my
application will have a C++ applicaiton that will be receiveing the data form
the Borland Code, and decoding the ACE, and then storing the data somewhere
(a class, a struct, a file, a stream... wherever is best) and then sending
this data to my C# code. I am expecting to use one class per distinct
message, and the messages wil continue to grow over time (thousands of
messages is not un-realistic) so I am also trying to find the least
maintenance heavy method to accomplish the task.

How would you recommend I get the data from my unmanaged C++ code and into
my C# application for quick stuffing into an Excel spreadsheet. Can it be
done is something close to real-time (maybe with a 1 - 2 second delay)?

Thanks in advance for any ideas, tips, hints, or suggestions.

Andrew S. Giles
Nov 16 '05 #1
5 5054
Andrew,

I'm not sure what you mean by ACE. Also, I don't understand why you use
C# at all, if you already have a C++ application that is doing the heavy
work (the transformation) . Instead of placing in yet another intermediary
format, why not have the C++ code just write the excel sheet?

If you really want to use managed code, you can do so within C++, that's
pretty easy, you just have to add a switch (I believe it is /clr).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andrew S. Giles" <An**********@d iscussions.micr osoft.com> wrote in message
news:42******** *************** ***********@mic rosoft.com...
I thought I would post here, as I am sure someone, somewhere has run into
this problem, and might have a good solution for me.

I am writing an applicaiton in C# that will accept data and then put it
into
an Excel spreadsheet. Easy, right? Well it is, until you have to get the
data from another application that is written in Borland C++ PowerBuilder
5.

The situation is that the Borland Code isnt going to get re-written (too
expensive, couple million lines of code) so we have to develop in Borland
still to handle some things, and the ACE is being used for ease of
communication between compilers (it is basically platform independent).
Unfortunately, the ACE code is not written in C#, but in C++. So, my
application will have a C++ applicaiton that will be receiveing the data
form
the Borland Code, and decoding the ACE, and then storing the data
somewhere
(a class, a struct, a file, a stream... wherever is best) and then sending
this data to my C# code. I am expecting to use one class per distinct
message, and the messages wil continue to grow over time (thousands of
messages is not un-realistic) so I am also trying to find the least
maintenance heavy method to accomplish the task.

How would you recommend I get the data from my unmanaged C++ code and into
my C# application for quick stuffing into an Excel spreadsheet. Can it be
done is something close to real-time (maybe with a 1 - 2 second delay)?

Thanks in advance for any ideas, tips, hints, or suggestions.

Andrew S. Giles

Nov 16 '05 #2
You say "get the data", however you need to explain what sort of interfaces
this C++ program has.
For instance, does it expose COM objects?
Does it have to be invoked as a new process, and passed a switch in order to
tell it to send the results to a file? Does it just print its output, printf
style?
Does it have Win32 DLLs that can be P-Invoked?

If it doens't have *any* method of actually communicating the data to
another program, i.e. it just expects itself to be the end-user program, then
you will have to basically extract the code that gets the data you want, and
write an interface for it - the best bet would be a Win32 DLL, so that you
can PInvoke it from C#.

But in order to know how your C# program can get the data, you need to know
what data's on offer, and how...

"Andrew S. Giles" wrote:
I thought I would post here, as I am sure someone, somewhere has run into
this problem, and might have a good solution for me.

I am writing an applicaiton in C# that will accept data and then put it into
an Excel spreadsheet. Easy, right? Well it is, until you have to get the
data from another application that is written in Borland C++ PowerBuilder 5.

The situation is that the Borland Code isnt going to get re-written (too
expensive, couple million lines of code) so we have to develop in Borland
still to handle some things, and the ACE is being used for ease of
communication between compilers (it is basically platform independent).
Unfortunately, the ACE code is not written in C#, but in C++. So, my
application will have a C++ applicaiton that will be receiveing the data form
the Borland Code, and decoding the ACE, and then storing the data somewhere
(a class, a struct, a file, a stream... wherever is best) and then sending
this data to my C# code. I am expecting to use one class per distinct
message, and the messages wil continue to grow over time (thousands of
messages is not un-realistic) so I am also trying to find the least
maintenance heavy method to accomplish the task.

How would you recommend I get the data from my unmanaged C++ code and into
my C# application for quick stuffing into an Excel spreadsheet. Can it be
done is something close to real-time (maybe with a 1 - 2 second delay)?

Thanks in advance for any ideas, tips, hints, or suggestions.

Andrew S. Giles

Nov 16 '05 #3
Terribly sorry for incompleteness.

No, it does not expose a COM object, so the COM interop is not an option.
It is spawned as its own process (or will be) so that it may receive the
decoded messages from a clearinghouse. How it gets the data (contained in
the decoded message) from where the C++ code receives it and into my C# is
where I am a touch lost. I thought about writing it to a file, and then just
reading that file into C#, but am concerned with speed and disk space usage
or fragmentation (after I delete all of these temp files after reading them).
The code does not have Win32 DLLs to be P/Invoked.

I will have some control over how the data is sent out of the C++ package, I
just want to find the best way to handle it. Would it be a good idea to
write functions int he C++ to be called from the C# code that are passed the
necessary parameters that I need filled?

Andrew

"Bonj" wrote:
You say "get the data", however you need to explain what sort of interfaces
this C++ program has.
For instance, does it expose COM objects?
Does it have to be invoked as a new process, and passed a switch in order to
tell it to send the results to a file? Does it just print its output, printf
style?
Does it have Win32 DLLs that can be P-Invoked?

If it doens't have *any* method of actually communicating the data to
another program, i.e. it just expects itself to be the end-user program, then
you will have to basically extract the code that gets the data you want, and
write an interface for it - the best bet would be a Win32 DLL, so that you
can PInvoke it from C#.

But in order to know how your C# program can get the data, you need to know
what data's on offer, and how...

"Andrew S. Giles" wrote:
I thought I would post here, as I am sure someone, somewhere has run into
this problem, and might have a good solution for me.

I am writing an applicaiton in C# that will accept data and then put it into
an Excel spreadsheet. Easy, right? Well it is, until you have to get the
data from another application that is written in Borland C++ PowerBuilder 5.

The situation is that the Borland Code isnt going to get re-written (too
expensive, couple million lines of code) so we have to develop in Borland
still to handle some things, and the ACE is being used for ease of
communication between compilers (it is basically platform independent).
Unfortunately, the ACE code is not written in C#, but in C++. So, my
application will have a C++ applicaiton that will be receiveing the data form
the Borland Code, and decoding the ACE, and then storing the data somewhere
(a class, a struct, a file, a stream... wherever is best) and then sending
this data to my C# code. I am expecting to use one class per distinct
message, and the messages wil continue to grow over time (thousands of
messages is not un-realistic) so I am also trying to find the least
maintenance heavy method to accomplish the task.

How would you recommend I get the data from my unmanaged C++ code and into
my C# application for quick stuffing into an Excel spreadsheet. Can it be
done is something close to real-time (maybe with a 1 - 2 second delay)?

Thanks in advance for any ideas, tips, hints, or suggestions.

Andrew S. Giles

Nov 16 '05 #4
Nicholas,

ACE is the Adaptive Communicaiton Environment
( http://www.cs.wustl.edu/~schmidt/ACE.html ).

My company is using it as a method to send messages between its array of
applications as needed. It was chosen because it is basically platform
independent.

The path for the data is roughly as follows: Some Borland code gets the
data from the hardware, and put it into a Class (this is Borland C++ code).
This Class is then put into an ACE message class, and sent out to wherever it
needs to go. There is an ACE gateway which sees this message, grabs it, and
routes it to an ACE consumer for use (the consumer is associated, in this
instance, with my code). The ACE consumer gets the ACE message, decodes it
to begin looking at the class (this is Visual C++ 6 code now). From here,
the data needs to get into my application for putting it into Excel (only
option at the moment, other options to follow, including Database, Crystal
reports, etc). I already have the interface that the user sees written in
C#, as well as the Export to Excel code in C#, which is why I would like to
not need to re-write it all over to C++.

Is re-writing the end-user app in Visual C++ 2003.NET the best way to go?

"Nicholas Paldino [.NET/C# MVP]" wrote:
Andrew,

I'm not sure what you mean by ACE. Also, I don't understand why you use
C# at all, if you already have a C++ application that is doing the heavy
work (the transformation) . Instead of placing in yet another intermediary
format, why not have the C++ code just write the excel sheet?

If you really want to use managed code, you can do so within C++, that's
pretty easy, you just have to add a switch (I believe it is /clr).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andrew S. Giles" <An**********@d iscussions.micr osoft.com> wrote in message
news:42******** *************** ***********@mic rosoft.com...
I thought I would post here, as I am sure someone, somewhere has run into
this problem, and might have a good solution for me.

I am writing an applicaiton in C# that will accept data and then put it
into
an Excel spreadsheet. Easy, right? Well it is, until you have to get the
data from another application that is written in Borland C++ PowerBuilder
5.

The situation is that the Borland Code isnt going to get re-written (too
expensive, couple million lines of code) so we have to develop in Borland
still to handle some things, and the ACE is being used for ease of
communication between compilers (it is basically platform independent).
Unfortunately, the ACE code is not written in C#, but in C++. So, my
application will have a C++ applicaiton that will be receiveing the data
form
the Borland Code, and decoding the ACE, and then storing the data
somewhere
(a class, a struct, a file, a stream... wherever is best) and then sending
this data to my C# code. I am expecting to use one class per distinct
message, and the messages wil continue to grow over time (thousands of
messages is not un-realistic) so I am also trying to find the least
maintenance heavy method to accomplish the task.

How would you recommend I get the data from my unmanaged C++ code and into
my C# application for quick stuffing into an Excel spreadsheet. Can it be
done is something close to real-time (maybe with a 1 - 2 second delay)?

Thanks in advance for any ideas, tips, hints, or suggestions.

Andrew S. Giles


Nov 16 '05 #5
Andrew,

You don't have to re-write it. You should be able to import the project
and then set the /clr flag and then use managed code.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andrew S. Giles" <An**********@d iscussions.micr osoft.com> wrote in message
news:95******** *************** ***********@mic rosoft.com...
Nicholas,

ACE is the Adaptive Communicaiton Environment
( http://www.cs.wustl.edu/~schmidt/ACE.html ).

My company is using it as a method to send messages between its array of
applications as needed. It was chosen because it is basically platform
independent.

The path for the data is roughly as follows: Some Borland code gets the
data from the hardware, and put it into a Class (this is Borland C++
code).
This Class is then put into an ACE message class, and sent out to wherever
it
needs to go. There is an ACE gateway which sees this message, grabs it,
and
routes it to an ACE consumer for use (the consumer is associated, in this
instance, with my code). The ACE consumer gets the ACE message, decodes
it
to begin looking at the class (this is Visual C++ 6 code now). From here,
the data needs to get into my application for putting it into Excel (only
option at the moment, other options to follow, including Database, Crystal
reports, etc). I already have the interface that the user sees written in
C#, as well as the Export to Excel code in C#, which is why I would like
to
not need to re-write it all over to C++.

Is re-writing the end-user app in Visual C++ 2003.NET the best way to go?

"Nicholas Paldino [.NET/C# MVP]" wrote:
Andrew,

I'm not sure what you mean by ACE. Also, I don't understand why you
use
C# at all, if you already have a C++ application that is doing the heavy
work (the transformation) . Instead of placing in yet another
intermediary
format, why not have the C++ code just write the excel sheet?

If you really want to use managed code, you can do so within C++,
that's
pretty easy, you just have to add a switch (I believe it is /clr).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Andrew S. Giles" <An**********@d iscussions.micr osoft.com> wrote in
message
news:42******** *************** ***********@mic rosoft.com...
>I thought I would post here, as I am sure someone, somewhere has run
>into
> this problem, and might have a good solution for me.
>
> I am writing an applicaiton in C# that will accept data and then put it
> into
> an Excel spreadsheet. Easy, right? Well it is, until you have to get
> the
> data from another application that is written in Borland C++
> PowerBuilder
> 5.
>
> The situation is that the Borland Code isnt going to get re-written
> (too
> expensive, couple million lines of code) so we have to develop in
> Borland
> still to handle some things, and the ACE is being used for ease of
> communication between compilers (it is basically platform independent).
> Unfortunately, the ACE code is not written in C#, but in C++. So, my
> application will have a C++ applicaiton that will be receiveing the
> data
> form
> the Borland Code, and decoding the ACE, and then storing the data
> somewhere
> (a class, a struct, a file, a stream... wherever is best) and then
> sending
> this data to my C# code. I am expecting to use one class per distinct
> message, and the messages wil continue to grow over time (thousands of
> messages is not un-realistic) so I am also trying to find the least
> maintenance heavy method to accomplish the task.
>
> How would you recommend I get the data from my unmanaged C++ code and
> into
> my C# application for quick stuffing into an Excel spreadsheet. Can it
> be
> done is something close to real-time (maybe with a 1 - 2 second delay)?
>
> Thanks in advance for any ideas, tips, hints, or suggestions.
>
> Andrew S. Giles


Nov 16 '05 #6

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

Similar topics

7
4388
by: Petr Prikryl | last post by:
Hi, Summary: In my opinion, the C-like prefix increment and decrement operators (++i and --i) should be marked as "syntax error". Current situation: try... (Python 2.4 (#60, ...)) >>> i = 1 >>> i
13
9649
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
6
1265
by: t.nicolson | last post by:
Hi there. I'm basically trying to expand a form within a table dynamically. To this end i've declared a placeholder within my table which i want to fill out using a javascript. eg. <div id=some_section_of_my_page>
4
34888
by: GrantS | last post by:
I am having a problem closing a popup window opened modally. When I try to close the window (when the user hits save button and the data has been processed), the Popup window opens as a full screen as a new window. The original window plus the Modally opened Pop remain in a separate window. What I want to do is close the popup and return to the original window with its view state maintained. The control use to fire the popup window...
4
1780
by: Greg Scharlemann | last post by:
I thought I had a workable approach to specifing which pages required a redirect in a config file, but it appears the way I'm attempting to do it is not going to work. The idea is that I can specify in the config file all of the pages that require a user to login otherwise the page will redirect if the user is not logged in. config.php looks like this: ----------------------
61
4953
by: Christoph Zwerschke | last post by:
On the page http://wiki.python.org/moin/Python3%2e0Suggestions I noticed an interesting suggestion: "These operators ≤ ≥ ≠ should be added to the language having the following meaning: <= >= != this should improve readibility (and make language more accessible to beginners).
6
4995
by: Lenny Wintfeld | last post by:
Hi I'm attempting additions/changes to a Java program that (among other things) uses XSLT to transform a large (96 Mb) XML file. It runs fine on small XML files but generates OutOfMemory exceptions with large XML files. I tried a simple punt of -Xmx512MB but that didn't work. In the future, the input XML file may become considerably bigger than 96 MB, so even if it did work, it probably would be putting off the inevitable to some later...
29
3652
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a string to a integer number. bool Convert(const string& str, int* pData); bool Convert(const string& str, int& data);
3
1990
by: Alan Isaac | last post by:
This is a simple question about actual practice. I just want to know how you (yes you) are approaching this problem. The problem: What is the recommended packaging of demo scripts or test scripts for a package to be distributed to others to "play with". (I.e., without "installing".)
0
9566
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
9389
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
10149
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...
1
9943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9828
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...
1
7370
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5271
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
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3918
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.