Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use an unregistered dll from c#?

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.

like image 322
cabgef Avatar asked May 19 '10 21:05

cabgef


People also ask

How do I unregister a DLL file?

To unregister a dll: Go to Start button and select Run. In the run box, type the command regsvr32 /u "path to the dll to be registered". i.e. "regsvr32 /u c:windowssystem32thisismy.dll"

How to register and unregister a DLL or ActiveX control?

How to Register and Unregister a DLL or ActiveX controls using Regsvr32.exe Regsvr32.exe is a program that you can use to register and unregister dynamic-link libraries (DLLs) and ActiveX controls (formerly called OLE Custom Controls) in the registry. Regsvr32.exe is installed in the System folder.

How do I run a DLL file in Windows?

Here is a guide: 1 Press Win+R to open Run. 2 Type the reg DLL command: regsvr32 “ [the path of the DLL file]”. The following is an example: 3 Click OK to execute the reg DLL command. 4 You will receive a confirmation message once the DLL file has been successfully registered. More ...

Do you need to register a DLL file when opening a program?

If you encounter a DLL error when you want to open a program on Windows, you might need to register a DLL file to solve the issue. Do you know how to fix unable to load DLL or failed to load DLL?


2 Answers

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.
like image 188
Remus Rusanu Avatar answered Sep 28 '22 13:09

Remus Rusanu


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.

like image 23
logicnp Avatar answered Sep 28 '22 12:09

logicnp