5

I have a custom dll (not registered) that I need to access via c#. How do I do this without registering the DLL?

Edit: It is a C++ dll.

cabgef
  • 1,398
  • 3
  • 19
  • 35
  • What kind of dll is it? An .NET-assembly, a native DLL, a COM-Object? What do you mean by register a dll? – Simon May 19 '10 at 21:58
  • Assuming you mean "not referenced by the current assembly" when you write "not registered", use [DllImport](http://msdn.microsoft.com/en-us/library/aa288468.aspx). – Randolpho May 19 '10 at 22:04

2 Answers2

5

See Registration-Free COM Interop:

Registration-free COM interop activates a component without using the Windows registry to store assembly information. Instead of registering a component on a computer during deployment, you create Win32-style manifest files at design time that contain information about binding and activation. These manifest files, rather than registry keys, direct the activation of an object.

Using registration-free activation for your assemblies instead of registering them during deployment offers two advantages:

  • You can control which DLL version is activated when more than one version is installed on a computer.
  • End users can use XCOPY or FTP to copy your application to an appropriate directory on their computer. The application can then be run from that directory.
Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569
1

I assume you want to use the functions exported from this dll via P/Invoke? If so, you only need to copy the dll to the same folder as your exe file. Then write C# declarations for the functions in the C++ dll that you want to use. See DllImportAttribute.

logicnp
  • 5,796
  • 1
  • 28
  • 32