C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2722
Number of posts: 5749

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
C# and unmanaged C++ DLL Posted by NoiK00 on 29 Jul 2010 at 11:32 PM
hey,

Is there a way to use an unmanaged C++ DLL in C#?

I've tried "converting" the DLL using tlbimp.exe to a RCW. But this gives a an error that it isn't a valid type library.

I've also used the metatag [dllimport()], this gives more result, but not correct(correct text but with preceding strange characters). I've tried using a function that.

Anymore tips on creating the DLL or C# calls?

The reason why it is a unmanaged C++ dll, is because of the files, provided by another company must be used. I've just created a few callable function to use the functions.

Thanx
Report
Re: C# and unmanaged C++ DLL Posted by anthrax11 on 30 Jul 2010 at 10:22 PM
Another DLL written in C++/CLI would give you a lot of control over the managed to unmanaged calls. It would be a mixed-mode library that links to the unmanaged DLL and exposes the required methods to the C# program through your own classes.

It's not the easiest approach, but it's more flexible and faster than the dllimport method. I've done this for several projects with great results.
Report
Re: C# and unmanaged C++ DLL Posted by NoiK00 on 31 Jul 2010 at 1:10 AM
By mixed mode you mean(starting from the class with entry point, C#):
1: C#
2: C++/CLI(DLL)
3: Unmanaged C++(DLL)

I'm gonna try this solution. I hope i don't get confused working with all these types ;)...
To be continued;



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.