DLL相关 [英] Dll Related

查看:167
本文介绍了DLL相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#项目中,当我尝试添加对BarcodeReader设备(csp2.dll)的dll的引用时.由于没有注册Windows组件或dll,出现错误. 解决方案

如果DLL是COM组件,请确保首先使用Regsvr32.exe注册它,然后添加引用.通过COM选项卡将其添加到您的项目中.

或者,您可以使用P/Invoke.例如:

 [DllImport(" ,EntryPoint = " )]
公共 静态 外部 平台调用上了解更多信息.


基于您的响应,它是一个C ++ DLL(此时假定为非托管DLL),您必须使用System.Runtime.InteropServices来访问DLL的功能.

如果您没有DLL的源代码,则可以使用称为"Depends"的实用程序找出要导出的方法.它将加载一个DLL并公开所有依赖的DLLS和导出的方法.

有了这些信息,您就可以使用PlatformInvoke创建适当的接口原型.


您确定您的dll是.net dll吗?


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.

解决方案

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.:

[DllImport("csp2.dll", EntryPoint="FUNCTION_NAME_IN_DLL")]
public static extern void MyImportedFunction();


Read more on Platform Invoke.


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.


Are you sure your dll is a .net dll?


这篇关于DLL相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆