Putting a DLL into a .NET project

  • Thread starter Thread starter TGF
  • Start date Start date
T

TGF

Hello,

I have a .NET C++ Project that I would like to include a dll file with
about 20 convenience functions. It seems every time I try to so this, I
wind up not doing something right. Can someone please tell me where I can
find instructions on exactly how to do this? The .NET app I am using needs
these functions and I do not want to just copy them into this .NET project.
Having them in a DLL is much more efficient as many other project I have
need these functions as well.
 
You can do this by going to the references. click on add
reference, then select the COM tab, If your COM object is
registered, then you should find it in the listbox or you
can browse and select it.
 
Hi,

if the DLL is a regular dll with simple c-functions as entry points you
could use the P/Invoke mechanism:

Sample from .NET 1.1 Reference:

#using <mscorlib.dll>
using namespace System;
using namespace System::Runtime::InteropServices;

[DllImport("msvcrt", CharSet=CharSet::Ansi)]
extern "C" int puts(String *);

int main()
{
String * pStr = S"Hello World!";
puts(pStr);
}


As far as i know is the masharling done at runtime and the dll has to be in
the path variable of the environment. That means that an exceptions is
thrown if the dll cannot be located or there is no matching function
prototype.

Regards, Walter
 
Back
Top