Using a VC++ DLL in a .Net DLL

NeuralJack

Well-known member
Joined
Jul 28, 2005
Messages
138
Hi, Id really like to use some C++ programming in a vb.net project of mine because as far as I know only C++ allows you to use true assembly code. I need a bit of clarification on the best way to go about this these days.

IJW - It Just Works - This does not apply to me because it only works in Visual C++ right? I can not use IJW in VB.Net as far as I know.

Does this mean my only real option is using P/Invoke? I have no problem with this until I see some articles where theyre the "Mangled Names" of the functions in the C++ DLL. That just seems incredibly ghetto to me. Is there a smoother method?
http://www.codeproject.com/KB/mcpp/usingcppdll.aspx

I simply want to create my own Visual C++ 2008 DLL that can be referenced and used in a VB.Net DLL.
 
You could create a DLL in straight C and therefore avoid the name mangling issue entirely, alternatively if you are creating a C++ DLL you could expose C functions that expose the functionality and call into the underlying C++ objects.

Have you tried creating a managed C++ project and seeing if you can use assembly code that way?
 
Mixed mode DLL

Are you planning on using this C++ DLL in non-managed applications? If not, I would recommend creating a mixed mode DLL using C++/CLI. You can write native code and call native C and C++ functions, including inline assembler if necessary, and still expose .NET types to managed applications. This will also execute a lot faster than platform invoke.

Good luck :cool:
 
Re: Mixed mode DLL

Thanks for the help guys.
I have actually tried making a managed C++/CLI project and everything seems to work fine, until i try to Run it in my VB.net project. The vb.net project actually seems to recognize it just fine, intellisense sees the classes and functions, it builds fine, etc.

But when I actually instantiate a class from the dll it silently fails. There is no error, and no other lines of code in the method that does the instantiation executes either (even the code before the instantiation line). This could definitely be an error on my part in the dll creation as I still have little experience with C++ dlls.

Ill have to work on it more soon.
 

Similar threads

E
Replies
0
Views
242
Eldeeb92
E
A
Replies
0
Views
784
ananda vardhana
A
D
Replies
0
Views
63
duoshock
D
E
Replies
0
Views
278
Eldeeb92
E
Back
Top