hi
can somebody tell me how to call dll made in c# project in the vc++ (VC 6.0) project???
the detail example of vc++ code would help me a lot.
thanx n regards.
chaitanya.

Recommended Answers

All 10 Replies

I think you can't do that!

I think you can't do that!

hi....
thanks for your reply. but we can call c# dll in vc++ code. i have done it....

thanks and regards.
chaitanya.

hi...
You can call dll made in C#.net in vc++(6.0) or vc++.Net.
for that you have to know basic of COM.
then It is very simple to call c# dll in the vc++.
You have to make .TLB (Type Library file) of your original c# DLL and use that
.TLB library in the VC++ code. For that you have to register .TLB file on your pc as well as it is neccessary to import that .TLB file in your vc++ apllication.
When you write C# DLL remember to use interfaces that would be implemented in the class.

For any querry please feel free to ask me....!
Thanx and Regards.
chaitanya.

i have done it....

Well no you haven't really, cos it's not a c# dll anymore (a .NET assembly) it's a COM library and you have to have written the C# library in a way that makes it compilable as a TLB.

Hmm having read some more I see I have misinterpreted your explanation, the assembly still exists and the COM client uses a generated and registered type library to be able to use it.

hi Holystyles....
you are right. I have realised my mistake while posting the thread. as one may missinterpret that we can use c# dll directly in VC++. but the fact that we have to make library file [.Tlb ] file and then only we can use it.

thanx n regards.
chaitanya.

hi...
You can call dll made in C#.net in vc++(6.0) or vc++.Net.
for that you have to know basic of COM.
then It is very simple to call c# dll in the vc++.
You have to make .TLB (Type Library file) of your original c# DLL and use that
.TLB library in the VC++ code. For that you have to register .TLB file on your pc as well as it is neccessary to import that .TLB file in your vc++ apllication.
When you write C# DLL remember to use interfaces that would be implemented in the class.

For any querry please feel free to ask me....!
Thanx and Regards.
chaitanya.

Hi Chaitanya.

I have a DLL that was being created in C#.net with an exported class/functions. Now, I want to call exported class/functions mentioned above from my code C++ code.

Just an add-on, Can I access all the c# exported classes in C++ console application? If Yes, the please provide pointers/sample code on this.

Thanks and Regards
PanB

LOL chaitanya you are answering your own question. :)

Solution:-
Yes, This is possible to Call a C# Dll into a VC++ project or a Managed Dll into a UnManaged project.
For this use the following linked
http://support.microsoft.com/kb/828736

thanks
Sandeep Tiwari
Software Engineer
AVL India Pvt. Ltd.-Gurgaon

It is kind of a headache. I have called C# written dlls in vb6 a few times via com interop. A lot of overhead involved - really lowers overall performance. Plus you need to add a bunch of attributes to your classes and create a seemingly pointless interface that your class must inherit. Therefore, if you don't want your original class to implement this interface, you have to write a seperate wrapper class that does. In other words, it may be faster to rewrite the code in c++ than it is to call it from c#.

Hi,
Can anyone post an example of this or refer some tutorial?
Best

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.