Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In C# project when I am trying to add reference to a dll for a BarcodeReader Device(csp2.dll). I am getting error as not a registered windows component or dll. make sure that the dll is existing.
Posted

If the DLL is a COM component, then make sure it is registered first using Regsvr32.exe, and then add a reference to it in your project through the COM tab.

Alternatively, you can use P/Invoke. E.g.:
C#
[DllImport("csp2.dll", EntryPoint="FUNCTION_NAME_IN_DLL")]
public static extern void MyImportedFunction();

Read more on Platform Invoke.
 
Share this answer
 
v2
Based on your response that it is a C++ DLL (assuming an unmanaged DLL at this point), you have to use System.Runtime.InteropServices to access the functionality of the DLL.

If you don't have the source code to the DLL, you can find out what methods are exported by using a utility called "Depends". It will load a DLL and expose all dependent DLLS and exported methods.

With that info, you can create appropriate interface prototypes with PlatformInvoke.
 
Share this answer
 
Are you sure your dll is a .net dll?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900