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

C++/CLI: Improved linkage to legacy Win32 DLLs?

_R
I've had to write a lot of code to interface C# to older Win32 DLLs.
Basically, an unmanaged C++ class talks directly to the Win32 DLL.
A managed C++ class encloses the unmanaged C++ class.
C# talks to the managed C++ class.

Lots of work. Is this simplified in C++/CLI? Any sample code
anywhere?

Nov 17 '05 #1
6 1529
What do you mean with simplified? You still have to wrap the native class by
a managed class and delegate the method calls to their corresponding native
method implementations.

Willy.

"_R" <_R@noemail.org> wrote in message
news:l5********************************@4ax.com...
I've had to write a lot of code to interface C# to older Win32 DLLs.
Basically, an unmanaged C++ class talks directly to the Win32 DLL.
A managed C++ class encloses the unmanaged C++ class.
C# talks to the managed C++ class.

Lots of work. Is this simplified in C++/CLI? Any sample code
anywhere?

Nov 17 '05 #2
_R
In the original version of my code I had two C++ wrappers--unmanaged
and managed. I did my best but it was tedious. From what little I've
read, I should be able to simplify to just one layer of C++ code,
right? In that declarations for managed vs unmanaged data are clear,
I can probably control that inline with handles vs pointers. Not sure
if the calls into the native Win32 DLL are more concise though. I'd
like to avoid using PInvoke, as some of the data types get obscure.
Is this made transparent in 2005beta2?

On Sat, 24 Sep 2005 20:31:06 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:
What do you mean with simplified? You still have to wrap the native class by
a managed class and delegate the method calls to their corresponding native
method implementations.

Willy.

"_R" <_R@noemail.org> wrote in message
news:l5********************************@4ax.com.. .
I've had to write a lot of code to interface C# to older Win32 DLLs.
Basically, an unmanaged C++ class talks directly to the Win32 DLL.
A managed C++ class encloses the unmanaged C++ class.
C# talks to the managed C++ class.

Lots of work. Is this simplified in C++/CLI? Any sample code
anywhere?


Nov 17 '05 #3
_R
On Sat, 24 Sep 2005 20:28:50 -0400, _R <_R@noemail.org> wrote:
In the original version of my code I had two C++ wrappers--unmanaged
and managed. I did my best but it was tedious. From what little I've
read, I should be able to simplify to just one layer of C++ code,
right? In that declarations for managed vs unmanaged data are clear,
I can probably control that inline with handles vs pointers. Not sure
if the calls into the native Win32 DLL are more concise though. I'd
like to avoid using PInvoke, as some of the data types get obscure.
Is this made transparent in 2005beta2?

On Sat, 24 Sep 2005 20:31:06 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:
What do you mean with simplified? You still have to wrap the native class by
a managed class and delegate the method calls to their corresponding native
method implementations.

Willy.

"_R" <_R@noemail.org> wrote in message
news:l5********************************@4ax.com. ..
I've had to write a lot of code to interface C# to older Win32 DLLs.
Basically, an unmanaged C++ class talks directly to the Win32 DLL.
A managed C++ class encloses the unmanaged C++ class.
C# talks to the managed C++ class.

Lots of work. Is this simplified in C++/CLI? Any sample code
anywhere?


Nov 17 '05 #4
_R
>On Sat, 24 Sep 2005 20:31:06 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:
What do you mean with simplified? You still have to wrap the native class by
a managed class and delegate the method calls to their corresponding native
method implementations.

Willy.

On Sat, 24 Sep 2005 20:28:50 -0400, _R <_R@noemail.org> wrote:
In the original version of my code I had two C++ wrappers--unmanaged
and managed. From what I've read, I should be able to simplify to just
one layer of C++ code,


PS: I could have stated that more clearly: I had two layers of C++
DLLs *in VS 2003*. I used an unmanaged wrapper to talk to the old
Win32 DLL. That wrapper collected functions into an organized class,
localized data, and generally imposed some structure.

A managed C++ DLL wrapped that unmanaged class so it could be called
easily from C#. Each DLL required different compile switches.

Q: Are there any new features in C++/CLI that would simplify this
process?

Nov 17 '05 #5
_R wrote:
On Sat, 24 Sep 2005 20:31:06 +0200, "Willy Denoyette [MVP]"
<wi*************@telenet.be> wrote:
What do you mean with simplified? You still have to wrap the native
class by a managed class and delegate the method calls to their
corresponding native method implementations.

Willy.


On Sat, 24 Sep 2005 20:28:50 -0400, _R <_R@noemail.org> wrote:
In the original version of my code I had two C++ wrappers--unmanaged
and managed. From what I've read, I should be able to simplify to
just one layer of C++ code,


PS: I could have stated that more clearly: I had two layers of C++
DLLs *in VS 2003*. I used an unmanaged wrapper to talk to the old
Win32 DLL. That wrapper collected functions into an organized class,
localized data, and generally imposed some structure.

A managed C++ DLL wrapped that unmanaged class so it could be called
easily from C#. Each DLL required different compile switches.

Q: Are there any new features in C++/CLI that would simplify this
process?


Well, you can certainly fold the 2 C++ DLLs (managed and unmanaged) into 1 :
just have the "organized class, localized data, and generally imposed some
structure" stuff be directly in the managed C++ DLL (MC++ and C++/CLI can
call directly on Win32).
Btw, you could have done the same thing in VS2003, although the syntaxic
clumsiness of MC++ would have made it cumbersome.

Arnaud
MVP - VC
Nov 17 '05 #6
_R
On Sun, 25 Sep 2005 11:48:35 +0200, "Arnaud Debaene"
<ad******@club-internet.fr> wrote:
_R wrote:
I had two layers of C++
DLLs *in VS 2003*. I used an unmanaged wrapper to talk to the old
Win32 DLL. That wrapper collected functions into an organized class,
localized data, and generally imposed some structure.

A managed C++ DLL wrapped that unmanaged class so it could be called
easily from C#. Each DLL required different compile switches.

Q: Are there any new features in C++/CLI that would simplify this
process?
Well, you can certainly fold the 2 C++ DLLs (managed and unmanaged) into 1 :
just have the "organized class, localized data, and generally imposed some
structure" stuff be directly in the managed C++ DLL (MC++ and C++/CLI can
call directly on Win32).


Thanks, Arnaud. Do you happen to know of any code samples that would
illustrate the new syntax?

Nov 17 '05 #7

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

Similar topics

15
by: _B | last post by:
Are there any book covering C++/CLI yet?
4
by: J | last post by:
I've just been reading a few articles on how Managed Extensions are now obsolete! Tough thing to hear, as I've been spending every spare moment studying them to try to solve a problem. I'd like...
3
by: _R | last post by:
Any late-breaking updates on C++/CLI docs or books? I've been waiting for Lippman's book, listed as published in September, but it looks like it's not available. My primary project is...
81
by: Don Kim | last post by:
I've been looking for a new IT position, and so far, the majority of work with respect to the Windows platform is C#/.Net, with some vb.net requests every so often. Even many of the C++/MFC/ATL...
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
1
by: Subodh | last post by:
Hi, We have legacy code in C/C++, I am writing a wrapper component in C++/ CLI that will allow using this legacy code functionality in C#, I have linked all my static libraries to this C++/CLI...
6
by: =?Utf-8?B?em9sb2Y=?= | last post by:
I have a lost of C# classes from many DLLs to use from my legacy C++ EXE application. Is there a generator that would use reflexion (for example) to generate a C++/CLI wrapper.
1
by: Kei | last post by:
I'm working on a VS 2005 solution which includes a project with WPF/ C# for UI work, and several projects with C++/CLI for business logic. I often ran into a problem where C++/CLI dlls cannot...
2
by: dan | last post by:
Our company has a large legacy application that we would like to convert to run under the CLR. The application consists of a large collection of Dlls that have been written in C++ and MFC over...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.