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.

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

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#.

This article has been dead for over six months. Start a new discussion instead.