Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Currently Using: Visual Basic.Net 2005, .Net Framework 2.0
  • Administrators
Posted

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?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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:

Never trouble another for what you can do for yourself.
Posted

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.

Currently Using: Visual Basic.Net 2005, .Net Framework 2.0
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...