NeuralJack Posted July 27, 2008 Posted July 27, 2008 Hi, I'd 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 they're 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. Quote Currently Using: Visual Basic.Net 2005, .Net Framework 2.0
Administrators PlausiblyDamp Posted July 28, 2008 Administrators Posted July 28, 2008 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
MrPaul Posted July 31, 2008 Posted July 31, 2008 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: Quote Never trouble another for what you can do for yourself.
NeuralJack Posted August 3, 2008 Author Posted August 3, 2008 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. I'll have to work on it more soon. Quote Currently Using: Visual Basic.Net 2005, .Net Framework 2.0
Recommended Posts