Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2004

Tip: Looking for answers? Try searching our database.

Trouble adding a reference to C++ DLL in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee Greco - 28 Oct 2004 16:05 GMT
A third party vendor has provided me with a DLL authored in C++ .Net.  The
vendor's package includes the DLL, .lib and all necessary .h files and sample
code to develop a C++ .NET app.  For the C++ sample project to run, the .lib
file needs to be added to the additional dependencies, the Stack Reserve Size
needs to be 2meg, the WIN32 directive must be included, and the runtime
library must be Multi-threaded Debug DLL.  The sample app includes a few
"extern template class DLLIMPORT std::vector<namespace::someclass*>"  
statements to access the objects in the external library.  I can get the C++
sample app to work just fine.

I am not a C++ developeer and would much rather develop an app using C# or
VB.Net, but when I try to add a reference to the DLL, I receive a "This is
not a valid assembly or COM component" error message.

How can I go about accessing the objects and methods in this external
library in a VB.Net or C# app?
Bonj - 31 Oct 2004 17:31 GMT
You would need to create a managed wrapper for it.
Something like:
Create a mixed dll that has a class to expose to C#, and that links to the
.lib file and includes the .h file that they provide, like
//thedll.cpp
#include "3rdparty.h" //contains, say, extern void the3rdpartyfunc();
#using <mscorlib.dll>
using namespace System;
public __gc class ThirdParty
{
   public:
    static void Call3rdPartyFunc()
   {
       the3rdpartyfunc();
   }
};
You should be able to then call this from C#.

>A third party vendor has provided me with a DLL authored in C++ .Net.  The
> vendor's package includes the DLL, .lib and all necessary .h files and
[quoted text clipped - 16 lines]
> How can I go about accessing the objects and methods in this external
> library in a VB.Net or C# app?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.