无法在visual studio项目中使用互操作dll

本文关键字:互操作 dll 项目 visual studio | 更新日期: 2023-09-27 18:17:16

我正在使用第三方dll。Interop.CRYPTLib。我试图使用它在我的。net应用程序,但我得到这个错误

"Retrieving the COM class factory for component with CLSID {AF6AF735-6D30-4E16-8AFA-FD4317E87D1B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

我尝试使用regsvr32,但现在我得到这个错误

The module was loaded but the entry-point dllregisterserver was not found

我使用regasm,它说类型注册成功,但它仍然失败与第一个错误,但当我使用/tlb:Interop.cryptlib。如果我得到错误

Interop.CRYPTLib.dll' was imported from a type library and cannot be re-exported to a type library.  Make sure the type library from
which the assembly was imported is registered.
我的代码是
var s = new CRYPTLib.EncryptDecryptClass();

无法在visual studio项目中使用互操作dll

Interop.CRYPTLib不是COM DLL -它只是CRYPTLib COM DLL的。net包装器。您需要实现CRYPTLib的DLL(可能是CRYPTLib. DLL)并使用regsvr32安装该DLL。