473,406 Members | 2,549 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,406 software developers and data experts.

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 5018
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.com

"Andrew S. Giles" <An**********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.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.com

"Andrew S. Giles" <An**********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.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.com

"Andrew S. Giles" <An**********@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.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.com

"Andrew S. Giles" <An**********@discussions.microsoft.com> wrote in
message
news:42**********************************@microsof t.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
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 =...
13
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...
6
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...
4
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...
4
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...
61
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: ...
6
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...
29
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...
3
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...
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: 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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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,...
0
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...
0
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,...
0
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...

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.