473,414 Members | 1,964 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,414 software developers and data experts.

VC6 <-> C#(net 2.0) interaction

Hi there.

We maintain a big VC6 project that we currently can´t convert to VS2005 for
various reasons. For our current project we need to establish a communication
channel between this VC6 project and another project that is running on
VS2005 C# and NET 2.0.

All our efforts so far were unsuccessful. Especially triggering events from
C++ to NET doesn´t work. We would be very thankfull for a set of sample
projects that actually interact VC6 <-C#. Any help would be very
appreciated!

Thanks a lot!
Jun 13 '07 #1
5 2110
Hi Elmar!
We maintain a big VC6 project that we currently can´t convert to VS2005 for
various reasons. For our current project we need to establish a communication
channel between this VC6 project and another project that is running on
VS2005 C# and NET 2.0.

All our efforts so far were unsuccessful. Especially triggering events from
C++ to NET doesn´t work. We would be very thankfull for a set of sample
projects that actually interact VC6 <-C#. Any help would be very
appreciated!
What is this VC6 project??? DLL/LIB/EXE/(In/Out)COM-Server ?

Greetings
Jochen
Jun 13 '07 #2
We maintain a big VC6 project that we currently can´t convert to VS2005
for
various reasons. For our current project we need to establish a
communication
channel between this VC6 project and another project that is running on
VS2005 C# and NET 2.0.

All our efforts so far were unsuccessful. Especially triggering events
from
C++ to NET doesn´t work. We would be very thankfull for a set of sample
projects that actually interact VC6 <-C#. Any help would be very
appreciated!
There are 2 ways:

1)build a plain C style DLL that communicates with your C++ app in whatever
way you see fit, and then consume that DLL in your .NET app.
..NET 2.0 has facilities for converting delegates to C style function
pointers so with some decent plumbing code, your should be able to make it
work.

2)build a .NET class library that communicates with your .NET app, and
register is for COM interop. then consume that COM class in your C++
application to work with the .NET application.

either way should work without too many problems.
--
Kind regards,
Bruno van Dooren MVP - VC++
http://msmvps.com/blogs/vanDooren
br**********************@hotmail.com
Jun 13 '07 #3
Hi Jochen.

It is an EXE-File.

Thanks.
Elmar

"Jochen Kalmbach [MVP]" wrote:
What is this VC6 project??? DLL/LIB/EXE/(In/Out)COM-Server ?

Greetings
Jochen
Jun 13 '07 #4
Can we discuss this a little bit more?
Assuming I have a simple test class library with one class:

------
using System;
using System.Collections.Generic;
using System.Text;

namespace vc6interop
{
public class Interop
{
public static string GreetMe(string name)
{
return "Hallo " + name;
}
}
}
------

....that is compiled with "expose as COM" flag turned on.
What do I have to do in order to call this method in C++?

I found some code that would fit this sample but it gives me a lot of errors.

------
GreetMe function;
CString result;

HINSTANCE hinstLib = LoadLibrary("vc6interop.dll");

if (hinstLib) {

function = (GreetMe) GetProcAddress(hinstLib, "GreetMe");
if (function)
result = (function) ("John");
BOOL fFreeResult = FreeLibrary(hinstLib);
}

// Das Ergebnis anzeigen
if (!hinstLib || !function)
printf("Error\n");
else
printf("Result: %s\n", result);
------
"Bruno van Dooren" wrote:
2)build a .NET class library that communicates with your .NET app, and
register is for COM interop. then consume that COM class in your C++
application to work with the .NET application.

either way should work without too many problems.
Jun 13 '07 #5

"Elmar" <El***@discussions.microsoft.comwrote in message
news:D7**********************************@microsof t.com...
Can we discuss this a little bit more?
Assuming I have a simple test class library with one class:

------
using System;
using System.Collections.Generic;
using System.Text;

namespace vc6interop
{
public class Interop
{
public static string GreetMe(string name)
{
return "Hallo " + name;
}
}
}
------

...that is compiled with "expose as COM" flag turned on.
What do I have to do in order to call this method in C++?

I found some code that would fit this sample but it gives me a lot of
errors.

------
GreetMe function;
Don't know what that means.

CString result;

HINSTANCE hinstLib = LoadLibrary("vc6interop.dll");
Nope, only .NET framework can load a .NET assembly.

>
if (hinstLib) {

function = (GreetMe) GetProcAddress(hinstLib, "GreetMe");
Nope, .NET code doesn't have an address until the JIT compiles it.

Instead, you must use CoInitialize to enable COM support in your
application, and CoCreateObject to create an instance of a .NET class. Then
you will be able to call the methods.
>

if (function)
result = (function) ("John");
BOOL fFreeResult = FreeLibrary(hinstLib);
}

// Das Ergebnis anzeigen
if (!hinstLib || !function)
printf("Error\n");
else
printf("Result: %s\n", result);
------
"Bruno van Dooren" wrote:
>2)build a .NET class library that communicates with your .NET app, and
register is for COM interop. then consume that COM class in your C++
application to work with the .NET application.

either way should work without too many problems.

Jun 13 '07 #6

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

Similar topics

11
by: Dan | last post by:
Workshop {Flash <-> PHP <-> MYSQL} 1-4 December 2003 in Milan (Italy) 4 full immersion days in a Flash/php/MySQL project start-up. The workshop is a unique opportunity for partecipants to...
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
5
by: ad | last post by:
I find there are some tag like <%= %> and <%# > in my .aspx file. What is the diffreence between <%= %> and <%# %>
17
by: roN | last post by:
Hi, I'm creating a Website with divs and i do have some troubles, to make it looking the same way in Firefox and IE (tested with IE7). I checked it with the e3c validator and it says: " This...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
3
by: ajay2552 | last post by:
Hi, I have a query. All html tags start with < and end with >. Suppose i want to display either '<' or '>' or say some text like '<Company>' in html how do i do it? One method is to use &lt,...
14
by: Michael | last post by:
Since the include function is called from within a PHP script, why does the included file have to identify itself as a PHP again by enclosing its code in <?php... <?> One would assume that the...
8
by: FFMG | last post by:
Hi, I have written a bunch of functions and I want to pass them thru a test engine to ensure that I haven't broken anything while working on something. I like the idea of http://qa.php.net/...
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: 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
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
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...
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,...

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.