c# - 无法从程序集 'ADODB._Recordset_Deprecated' 加载类型 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

标签 c# vb6 interop adodb

看,我遇到了一个问题,它开始让我有些头痛,因为我找啊找,但仍然不走运。

我必须从 C# 执行 DLL 的方法,这个 DLL 是 4 年前在 VB 6.0 中创建的,并且在 COM 中注册。它使用 ADOB.Recordset 作为我必须执行的方法的返回类型(没有可用的源代码:S)

我一直在寻找如何加载和执行该 DLL。

我第一次加载它时遇到了问题,我无法使用Server.CreateObject、Assembly.Load、Assembly.LoadFrom加载它,所以我尝试从 COM 和视觉对象的引用中添加它Studio 将其导入到 Bin 文件夹中,名称为 Interops.[Dll 名称]

当 Y 尝试使用它时,它给我编译错误,它说:

Error   1   No overload for method 'SelArregloCobertura' takes '6' arguments

参数在其类型和所有内容内都是正确的。很确定这一点

所以我尝试用反射来执行它,这是代码:

 ADODB.Recordset rs = new ADODB.Recordset();       
        string strRamo = "70";
        string strSubramo = "01";
        string strOficina = "070";
        int iClaveSolicitud = 7118;
        string strModulo = "0";
        int iInciso = 1;

        Poliza.clsdNTCoberturaClass oClass = new Poliza.clsdNTCoberturaClass();

        MethodInfo miSelArregloCobertura = oClass.GetType().GetMethod("SelArregloCobertura");
        miSelArregloCobertura.Invoke(oClass, new object[] { "70", "01", "070", 7118, "0", 1 });
        //oClass.SelArregloCobertura(strRamo, strSubramo, strOficina, iClaveSolicitud, strModulo, iInciso);

(我评论了给我编译错误的行) 而且错误是不同的,不是编译错误它给了我问题中的错误

Could not load type 'ADODB._Recordset_Deprecated' from assembly 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

当我查看 dll 的元数据时,它看起来像这样。

 [Guid("757AC98D-3800-406F-BA47-AEDAF2EBBCDB")]
    [TypeLibType(2)]
    [ClassInterface(0)]
    public class clsdNTCoberturaClass : _clsdNTCobertura, clsdNTCobertura
    {
        public clsdNTCoberturaClass();

        [DispId(1610809344)]
        public virtual ADODB._Recordset_Deprecated SelArregloARenovar(string dFecha1, string dFecha2, string strNumOfic, short strCveAge, string strRamo);
        [DispId(1610809347)]
        public virtual ADODB._Recordset_Deprecated SelArregloCobertura(string strRamo, string strSubRamo, string strNumOfic, int lCveSol, string strModulSol, int lCveInc);
        [DispId(1610809348)]
        public virtual ADODB._Recordset_Deprecated SelArregloCobEst(string strRamo, string strSubRamo, short intCveInc, short intAnio, int lNumRec, string strOficRecl);
        [DispId(1610809349)]
        public virtual ADODB._Recordset_Deprecated SelArregloCobEstim(string strRamo, string strSubRamo, short intCveInc, short intAnio, int lNumRec, string strOficRecl);
        [DispId(1610809346)]
        public virtual ADODB._Recordset_Deprecated SelArregloNvaCobertura(string strRamo, string strSubRamo, string strNumOfic, int lCveSol, string strModulSol, int lCveInc, short intAnio, string strOficRecl, string intnumrec);
        [DispId(1610809345)]
        public virtual ADODB._Recordset_Deprecated SelCobertura(string strRamo, string strSubRamo, string strCveCober);
        [DispId(1610809350)]
        public virtual ADODB._Recordset_Deprecated SelEstCobertura(string strRamo, string strSubRamo, short intAnio, string strOficRecl, int lNumRec, short intCveInc, string strCveCober);
    }

所以我认为导入步骤有问题,

任何人都知道如何使其工作,或者有另一种形式可以从在 COM 中注册的 dll 加载执行方法?

任何帮助都会非常感激。

提前致谢。

最佳答案

检查Breaking change in MDAC ADODB COM components in Windows 7 Service Pack 1

警告:这是一篇 looooooooong 的帖子,您的浏览器将挂起一段时间。

更新:微软决定恢复类型库并剥离新接口(interface),请参阅 Windows 8 Developer Preview build contains the complete fix of the ADO typelib issue

关于c# - 无法从程序集 'ADODB._Recordset_Deprecated' 加载类型 'ADODB, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6851911/

相关文章:

try finally 中变量的 C# 生命周期

vb6 - 在 Visual Basic 6 中绕过 64k 限制

winapi - 何时调用 CloseTouchInputHandle

vb6 - VB6 中的动态内存分配

c# - 如何创建 SendMessage WM_KEYDOWN 的 lParam

c# - 为非托管代码提供托管控制句柄 - 访问冲突

php - 使用 openssl_encrypt AES-CBC 实现 Python 到 PHP 兼容的 AES 加密

c# - 如何从实体连接字符串中获取数据源、用户 ID 和密码?

c# - Moq When(Func<bool>) 方法的使用

c# - 在 C# 字典中仅通过一次查找查找或插入