473,466 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to use a C# ControlLibrary in VC6

Hi,
I have developed a C# Control Library with a number of window forms
controls.
I would now like to start using them in any old project written in VC6 using
MFC.

I have tried adding inserting components and controls to project, but it
doesn't list it there.
If in VC6, I right click on the dialog and select insert ActiveX it does
actually list it here.
But I have have a number of methods/functions that I want to be able to
invoke from the VC6 side.

So was wondering if anybody had done this before and if they could give me
an pointers or sample code to see where I'm going wrong.

Thanks

Wayne
Nov 22 '05 #1
2 2082
Yeah, what you have to do is expose the .NET code to COM, then, import them
into the VC6. To do this, you need to create a Type Library (.TLB) using the
..NET tool TlbExp.exe and using the #import directive. When referencing a type
library from C++, you must either specify the raw_interfaces_only option or
import the definitions in the base class library, Mscorlib.tlb. It would look
like this:

#import "..\app\app.tlb" raw_interfaces_only

or like this:

#import "mscorlib.tlb"
#import "..\LoanLib\LoanLib.tlb"

COM developers can call methods on the .NET object the same way they call
methods on any unmanaged type. For example, the COM CoCreateInstance API
activates .NET objects. Calling the code would look like this:

IObjPtr pObj(__uuidof(TypeClass));
pObj->WhateverMethod();

Hopefully that helps.

"Wayne Gibson" wrote:
Hi,
I have developed a C# Control Library with a number of window forms
controls.
I would now like to start using them in any old project written in VC6 using
MFC.

I have tried adding inserting components and controls to project, but it
doesn't list it there.
If in VC6, I right click on the dialog and select insert ActiveX it does
actually list it here.
But I have have a number of methods/functions that I want to be able to
invoke from the VC6 side.

So was wondering if anybody had done this before and if they could give me
an pointers or sample code to see where I'm going wrong.

Thanks

Wayne

Nov 22 '05 #2
Yeah, what you have to do is expose the .NET code to COM, then, import them
into the VC6. To do this, you need to create a Type Library (.TLB) using the
..NET tool TlbExp.exe and using the #import directive. When referencing a type
library from C++, you must either specify the raw_interfaces_only option or
import the definitions in the base class library, Mscorlib.tlb. It would look
like this:

#import "..\app\app.tlb" raw_interfaces_only

or like this:

#import "mscorlib.tlb"
#import "..\LoanLib\LoanLib.tlb"

COM developers can call methods on the .NET object the same way they call
methods on any unmanaged type. For example, the COM CoCreateInstance API
activates .NET objects. Calling the code would look like this:

IObjPtr pObj(__uuidof(TypeClass));
pObj->WhateverMethod();

Hopefully that helps.

"Wayne Gibson" wrote:
Hi,
I have developed a C# Control Library with a number of window forms
controls.
I would now like to start using them in any old project written in VC6 using
MFC.

I have tried adding inserting components and controls to project, but it
doesn't list it there.
If in VC6, I right click on the dialog and select insert ActiveX it does
actually list it here.
But I have have a number of methods/functions that I want to be able to
invoke from the VC6 side.

So was wondering if anybody had done this before and if they could give me
an pointers or sample code to see where I'm going wrong.

Thanks

Wayne

Nov 22 '05 #3

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

Similar topics

1
by: Wayne Gibson | last post by:
Hi, I have developed a C# Control Library with a number of window forms controls. I would now like to start using them in any old project written in VC6 using MFC. I have tried adding...
3
by: Ahmet | last post by:
Hi; How can I get control list (Controls) of a form in a dll dynamically activated using Activators.CreateInstance. I need all controls names and attributes of one form which is in one dll. Is...
9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
10
by: Nak | last post by:
Hi there, I'm having problems with the Toolbox in VB.NET 2002 Standard. I have 2 class libraries, 1 contains licensing classes and references nothing but standard namespaces and the other...
1
by: aidancasey | last post by:
I have written a custom control called CheckboxDataList that derives from the DataList webControl. My control contains a public property called CheckedValues. The type of this property is a...
6
by: cyriel1920 | last post by:
Hi, I use the selectednodestyle with a white background so the user can see which item was chosen in the treeview navigation. The nodes have a navigateURL with a target to another frame....
1
by: AAOMTim | last post by:
I would like to create a class library that uses a ListItemControl, but when I try to create the class withthe following using atetments, it doesn't recognize the System.Web.UI components: using...
7
by: John D'oh | last post by:
Hello, I have been going through the MSDN Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features. Everything was going fine and I was able to...
3
by: RvGrah | last post by:
I have a user control with eight text boxes, if I start typing in the first text box in the tab order all is well, but if I mouse click into another box and start typing the text goes into the frst...
1
by: A Popat | last post by:
This is my first question here, so apologies if I have made a mistake. I am developing a collection of small games using WPF with C# but have been having real difficulty in being able to load and...
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
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...
1
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.