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

How to use a c++ class in a c# project?

Hi,

I'm using VS.NET and I'm trying to use a c++ class in a c# project.

How can I use the c++ class - the code-completion doesn't 'read' the
functions and properties and won't even recognize that there is a class with
that name (the name of the c++ class). The two classes are in the same
namespace.

Do I miss something?

Mads
Nov 15 '05 #1
4 1449
are you using managed c++ or unmanaged?
if your using managed, compile the class into a .NET DLL and it should
recognize it fine,
if it is unmanaged code, you can put it in a regular dll and use pInvoke to
access the methods.
"Mads Jacobsen" <ma***********@get2net.dk> wrote in message
news:u4**************@TK2MSFTNGP09.phx.gbl...
Hi,

I'm using VS.NET and I'm trying to use a c++ class in a c# project.

How can I use the c++ class - the code-completion doesn't 'read' the
functions and properties and won't even recognize that there is a class with that name (the name of the c++ class). The two classes are in the same
namespace.

Do I miss something?

Mads

Nov 15 '05 #2
Mads... Also, if it is an ATL dll, the compiler will wrap it for you
and you
can call it from C#.

http://support.microsoft.com/default...b;en-us;305990

Generate a primary interop assembly from Visual Studio .NET. To invoke
Tlbimp.exe to generate the interop assembly that you need, click Add
Reference on the Project menu, click the COM tab, and then select the
entry for the COM server.

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #3
"Kovan" <ju********@rogers.com> wrote in message
news:S1*********************@news04.bloor.is.net.c able.rogers.com...
are you using managed c++ or unmanaged?
if your using managed, compile the class into a .NET DLL and it should
recognize it fine,
if it is unmanaged code, you can put it in a regular dll and use pInvoke to access the methods.


Does it have to be a COM dll? Because I have a regular dll with no com
interface, I can't add reference from my project to it saying that it has
not COM interfance.

/m
Nov 15 '05 #4
no it doesnt have to be COM
if its a regular dll,
treat it as such

http://msdn.microsoft.com/msdnmag/is...T/default.aspx

"Muscha" <mu****@no.spam.net> wrote in message
news:un**************@TK2MSFTNGP12.phx.gbl...
"Kovan" <ju********@rogers.com> wrote in message
news:S1*********************@news04.bloor.is.net.c able.rogers.com...
are you using managed c++ or unmanaged?
if your using managed, compile the class into a .NET DLL and it should
recognize it fine,
if it is unmanaged code, you can put it in a regular dll and use pInvoke

to
access the methods.


Does it have to be a COM dll? Because I have a regular dll with no com
interface, I can't add reference from my project to it saying that it has
not COM interfance.

/m

Nov 15 '05 #5

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

Similar topics

2
by: Nancy | last post by:
I have the following situation and could use some advise. I have a Base Class CreditReport, classes BoatCreditReport and HomeCreditReport Inherit from CreditReport. I would like to have the...
2
by: Rafael Pivato | last post by:
Hi, How can I make two libraries with referencing each other ? --------- Thanks, Rafael Pivato
8
by: Brett Romero | last post by:
I have this situation: myEXE <needs< DerivedClass <which needs< BaseClass Meaning, myEXE is using a type defined in DerivedClass, which inherits from BaseClass. I include a reference to...
5
by: D Witherspoon | last post by:
What is happening is that I have a class (ClassA) that inherits a class (ClassB) which inherits System.Net.Mail.MailMessage Project 1 references Project 2, Project 2 references Project 3. ...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
16
by: Robert Dufour | last post by:
Here's the class code snippet Imports System.Configuration.ConfigurationManager Public Class Class1 Public _strTestSetting As String Public Sub SetTestsetting()
4
by: Alan Mailer | last post by:
Again, I'm new to VB.net and there is something I need help with: Like (I assume) many of us, over time I want to be able to create some VB.net classes that I might want to use in more than one...
5
by: Ohad weiss | last post by:
Hi all, I have a class in project A. At the same solution, I have another project - named project B. I want to write a piece of code in that class from project B that finds the class in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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...

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.