看,我面临问题,它开始让我头疼,因为我看起来很神情,但仍然没有运气。
我必须从C#执行DLL的方法,这个DLL就像4年前在VB 6.0中创建的那样,它在COM中注册。它使用ADOB.Recordset作为我必须执行的方法的返回类型(没有源代码avaialble:S)
我一直在搜索如何加载和执行该DLL。
我第一次加载时遇到问题,我无法用Server.CreateObject, Assembly.Load, Assembly.LoadFrom
加载它,所以我尝试从COM的引用添加它,Visual Studio将它导入Bin文件夹中,名称为Interops。[ Dll的名称]
当Y尝试使用它时,它会给我编译错误,它说:
Error 1 No overload for method 'SelArregloCobertura' takes '6' arguments
参数在其类型和所有内容中都是正确的。很确定这个
所以我尝试用Reflection执行它,这就是代码:
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加载执行方法?
任何帮助都会非常准确。
提前致谢。
答案 0 :(得分:4)
检查Breaking change in MDAC ADODB COM components in Windows 7 Service Pack 1
警告:这是一个looooooooong帖子,您的浏览器会暂停一段时间。
更新:Microsoft决定恢复类型库并剥离新接口,请参阅Windows 8 Developer Preview build contains the complete fix of the ADO typelib issue
答案 1 :(得分:2)
Microsoft Connect有一个页面,包括一些解决方法信息。它与对Windows 7 SP1中引入的ADODB的更改有关。
其中一个解决方法详见Microsoft Support Page。