C# 从DLL调用进行的转换无效

C# 从DLL调用进行的转换无效,c#,.net,dll,C#,.net,Dll,我正在将我的项目引用到从硬件供应商处获得的外部DLL,并遇到以下错误: Exception thrown: 'System.FormatException' in mscorlib.dll Exception thrown: 'System.FormatException' in mscorlib.dll Exception thrown: 'System.FormatException' in Microsoft.VisualBasic.dll Exception thrown: 'Syste

我正在将我的项目引用到从硬件供应商处获得的外部DLL,并遇到以下错误:

Exception thrown: 'System.FormatException' in mscorlib.dll
Exception thrown: 'System.FormatException' in mscorlib.dll
Exception thrown: 'System.FormatException' in Microsoft.VisualBasic.dll
Exception thrown: 'System.InvalidCastException' in Microsoft.VisualBasic.dll
An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string "8010001D" to type 'Integer' is not valid. 
然而,Visual Studio 2017中没有编译错误,只有运行时崩溃。同事可以在VisualStudio2012中很好地调试它。我曾尝试将目标平台从.NET 2.0更改为.NET 4.5,但仍然失败

这是源代码。目前,我只是想看看引用是否正确,但在我看来应该没有任何问题

class Program
{
    static void Main(string[] args)
    {
        MyKad reader = new MyKad(); //the app breaks here. MyKad() is a dll object
        Console.WriteLine("Testing app starts..");
        if(reader.Connect())
        {
            Console.WriteLine("Obj creation succeed");
        }
        else
        {
            Console.WriteLine("Obj creation failed");
        }
    }
}
MyKad()
来自dll。我可以看到方法信息,但看不到实际的代码。我是否在项目配置中遗漏了任何遗留设置

下面是调用堆栈

    Microsoft.VisualBasic.dll!Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger( Value) Line 788 + 0x84 bytes    Basic
CSMyKad.dll!CSMyKad.MyKad.UserControl_Initialize() + 0x73 bytes 
CSMyKad.dll!CSMyKad.MyKad.MyKad() + 0x11e bytes 
MyKadLib.exe!MyKadLib.Program.Main(string[] args) Line 16   C#

错误很明显。。。它正在尝试将
8010001D
转换为整数。。。可能是app.config中的某个内容,或者它是一个默认值是的,它非常清楚,但它来自DLL。我想知道这个DLL如何在VS2012中运行良好。我将尝试查看app.config配置中没有出现这样的十六进制值。这是一个嵌入在DLL中的常量,我想它是用来作为字节的。如果你找不到任何东西,另一个窍门就是用它来查看DLL(MyKad)。你的调用堆栈可能比你给我们写的要长。。。您查看此处引用的方法,并尝试预测它从何处获取数字,以及它如何尝试转换数字。数字可能来自注册表,也可能来自谁知道vb.net使严格类型编程风格的典型结果可能来自哪里。假设您有源代码,使用OptionStrictOn是清除此类错误的一个好方法。它在错误处理代码上失败,这种代码从未经过测试。“8010001D”是一个十六进制错误代码,表示SCARD_E_NO_服务,“智能卡资源管理器未运行。”