Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use c# Dll in vc++?

I have created a dll using command line (csc). Suppose that dll contains Add(int,int) method. Now I want to use that add function in vc++??

How to do this?

Your Help will be Greatly Appreciated.

Here is what I am doing.

vcproj; for this project i have right click and linker section add additional dependencies.added the path where dll resides.

main.cpp

using namespace Test

void main()

{

  demo d;

  d.add(5,5);

}

error namespace Test Does not exist.

How to resolve this?

I need to use that dll as in unmanaged code

like image 227
Cute Avatar asked Jun 11 '09 12:06

Cute


People also ask

How is C used?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

Is C easy for beginners?

C is not just what students use to learn programming. It's not an academic language. And I would say it's not the easiest language, because C is a rather low level programming language. Today, C is widely used in embedded devices, and it powers most of the Internet servers, which are built using Linux.

What does %c mean in C?

%d is used to print decimal(integer) number ,while %c is used to print character . If you try to print a character with %d format the computer will print the ASCII code of the character.

How can I learn C language perfectly?

Get started with C. Official C documentation - Might be hard to follow and understand for beginners. Visit official C Programming documentation. Write a lot of C programming code - The only way you can learn programming is by writing a lot of code.


1 Answers

Your C# assembly needs the ComVisible attribute (among a few other things).

[assembly: ComVisible(true)] 

There's a guide to doing this here.

like image 76
Matt Brindley Avatar answered Oct 25 '22 02:10

Matt Brindley