【问题标题】:My DLLImport works well at Winform Application but got Exception at Asp.net WebFormApplication我的 DLLImport 在 Winform 应用程序中运行良好,但在 Asp.net WebFormApplication 中出现异常
【发布时间】:2012-06-15 11:56:47
【问题描述】:

我的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)

【问题讨论】:

    标签: asp.net winforms dllimport


    【解决方案1】:

    SEHException 是从非托管代码中抛出的。 使用调试器:Debug > Exceptions打开Thrown flag for Win32 Exceptions

    另外,尝试将非托管函数更改为使用StdCallCheck the calling convention 在托管和非托管方面。使用错误的调用约定会影响调用堆栈的状态。

    【讨论】:

      猜你喜欢
      • 2012-11-05
      • 1970-01-01
      • 1970-01-01
      • 2020-03-05
      • 2017-05-22
      • 2019-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多