473,765 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a C++ class to have a .NET interface

There is a 3rd party library that is a bit complex, has a number
of functions and structs and variable length data, the whole bit.
I saw Eric Gunnerson's July 14, 2002, article "Using Existing Code
in C#". He talks about four different ways to wrap the code in
C++, the last one is: "Modifying a C++ class to have a .NET
interface", but he never talks about how to actually do this. Can
anyone point me to documentation about how to do this?

Sam
Nov 17 '05 #1
3 1004
Sam Carleton wrote:
There is a 3rd party library that is a bit complex, has a number
of functions and structs and variable length data, the whole bit.
I saw Eric Gunnerson's July 14, 2002, article "Using Existing Code
in C#". He talks about four different ways to wrap the code in
C++, the last one is: "Modifying a C++ class to have a .NET
interface", but he never talks about how to actually do this. Can
anyone point me to documentation about how to do this?


You can use managed extensions (MC++) to wrap an unmanaged class. The
managed wrapper can then be used in C# or other managed code.
--
Ajay Kalra [MVP - VC++]
aj*******@yahoo .com

Nov 17 '05 #2
On 2005-03-25, Ajay Kalra wrote:
Sam Carleton wrote:
There is a 3rd party library that is a bit complex, has a
number of functions and structs and variable length data, the
whole bit. I saw Eric Gunnerson's July 14, 2002, article
"Using Existing Code in C#". He talks about four different
ways to wrap the code in C++, the last one is: "Modifying a C++
class to have a .NET interface", but he never talks about how
to actually do this. Can anyone point me to documentation
about how to do this?


You can use managed extensions (MC++) to wrap an unmanaged
class. The managed wrapper can then be used in C# or other
managed code.


Wonderful! Can you give me the title of an MSDN Document to get
me pointed in the right direction? So far, the best I have been
able to find is: "Interopera ting with Unmanaged Code" From what
it looks like to me, this only deals with calling an unmanaged
DLL, not wrapping a unmanaged C++ class in a managed C++ class.

Sam

Nov 17 '05 #3
This article is little dated but it should still work fine:
http://msdn.microsoft.com/msdnmag/issues/02/02/ModernC/

It demonstrates wrapping a unmanaged class in a managed object.

--------
Ajay Kalra
aj*******@yahoo .com

Nov 17 '05 #4

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

Similar topics

1
14945
by: MKoleoso | last post by:
Problem: C#- Unable to create instance of a class implementing from an interface I have: namespace someNamespace { public __gc class SomeClass1 { }
15
12829
by: Brian Rogers | last post by:
Hello everyone, I apologize for the cross and re-post, but I am still searching for an answer. Why can C++ can create this object, but C# can't? I am trying to create an instance of the default FTP asynchronous pluggable protocol adaptor, so I can analyse the traffic between urlmon.dll (IE) and the FTP server. The language I am attempting to use is C#.
4
17028
by: Ray | last post by:
I want to dynamically load DLLs (created from VB) and instantiate a class with a particular name, like "ProcessClass". I am able to load the DLL and confirm there is a class by that name BUT I can't seem to create it or call methods to this newly created instance. I have the following code: public class Script {
0
1601
by: Greg Conely via .NET 247 | last post by:
I am creating a application that will be using plugins. I am doing this so that when I want to let this application work with another type of dbase system, I only have to write\install one plugin, not the entire app. I have created a base interface, it looks like: public interface myModel sub Initialize(byref DisplayPanel) sub Connect() sub Disconnect() sub Query() ...
7
1775
by: Ron | last post by:
Hello, I have 4 classes that use 4 DTS packages on 4 different tables. So I have Dim cls1 As New clsDTS1, cls2 As New clsDTS2 Dim cls3 As New clsDTS3, cls4 As New clsDTS4 Each class has a common property called DataPath cls1.DataPath = strPath
0
1375
by: sameem.samad | last post by:
Hi, I have a solution which has 3 layers - GUI, Interface Layer and web service layer. GUI layer is referencing Interface Layer and Web service layer also pointing to interface layer. GUI layer has following Code: Dim obj as IFedService = IFedService.BrokerHelper.GetAddress Dim str as string = obj.GetAddress(ObjData)
37
3309
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html PEP: XXX Title: The create statement
18
2720
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html In this post, I'm especially soliciting review of Carl Banks's point (now discussed under Open Issues) which asks if it would be better to have the create statement translated into:
2
5566
by: Joseph Geretz | last post by:
When I create a Form, the VB IDE creates the following files in the following hierarchy: Form1.cs Form1.Designer.cs Form1.resx Both Form1.cs and Form1.Designer.cs are partial implementations of a single physical class definition. The VB IDE properly recognizes Form1.cs as a Form (i.e. double-clicking opens the Form designer). It also recognizes
0
9568
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
9398
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
10160
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
9832
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
6649
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
5275
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
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
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
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.