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

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 17 '05 #1
1 1086
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 17 '05 #2

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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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...

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.