问题描述
- vs加载第三方动态库,调试模式能正常读取,但是单独执行exe,读卡出现问题!
-
[DllImport("RWManager.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, EntryPoint = "ReadBase", SetLastError = true)] public static extern int dll_ReadBase(StringBuilder pInput, StringBuilder pOutput); public int ReadTest() { StringBuilder pInput = new StringBuilder(); pInput.Append("@0000=1@0002=mw@0010=LogIC@000B=2@000H=1@"); StringBuilder pOutput = new StringBuilder(); pOutput.Length = 256; pOutput.Capacity = 512; int flag = dll_ReadBase(pInput, pOutput); MessageBox.Show(flag.ToString()); return flag; }
RWManager.dll是读卡器厂家提供的动态库,是用delphi 写的,dll 中的ReadBase方法要求传入的是pchar值,在网上查资料,C#调用的时候传入StringBuilder,程序在调试模式,能正常读卡,单独执行exe,却读卡异常!很奇葩的问题,有没有大神遇到过相同的问题,求指导!!!
时间: 2024-12-03 16:29:16