我的DLLImport在Winform Application上运行良好,但在Asp.net WebFormApplication中得到了Exception

时间:2012-06-15 11:56:47

标签: asp.net winforms dllimport

我的DLLImport(Delphi DLL)适用于Winform应用程序,但我的ASP.net WebForm应用程序(在IIS 7上)出现异常。

有人可以告诉我为什么以及如何处理它?

[DllImport("DLL_YINLIAN_INTERFACE.dll", EntryPoint = "YL_SetParam", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
        static extern int YL_SetParam(int iParamIndex, byte[] ucParamBuffer);

以下是调试时的异常:

System.Runtime.InteropServices.SEHException (0x80004005): 
   External component has thrown an exception.
   at JFTHardAPI.SandTran.YL_SetParam(Int32 iParamIndex, Byte[] ucParamBuffer)

1 个答案:

答案 0 :(得分:0)

从非托管代码抛出

SEHException。 使用调试器:Debug > Exceptions启用 Thrown flag for Win32 Exceptions

另外,尝试更改非托管功能以使用StdCall。 Managed和UnManaged方面的Check the calling convention。使用错误的调用约定可能会影响调用堆栈的状态。 enter image description here