C# Web 中的 AccessViolation 异常 API

AccessViolation Exception in C# Web API

通过 C# Web 访问 SAP RFC 时遇到错误 API。以下是详细信息: 我能够从存储在 out 参数中的 SAP RFC 获得响应,但在将其返回到我的函数时抛出异常。这是代码:

    internal string FromBupaToBupaGuid(string sBupa)
    {
        using (SAPContext db = new SAPContext(base.GetConnectStringForRfcUser()))
        {
            ERPConnect.LIC.SetLic(base.GetLicenseKey());
            string sBupaGuid;
            SAPContext.MESSAGESTable mESSAGESTable = new SAPContext.MESSAGESTable();
            sBupa = ToBupa(sBupa);
            db.IST_GET_BPARTNER_GUID(out sBupaGuid, sBupa, mESSAGESTable);

            return sBupaGuid;
        }
    }

异常信息如下:

System.AccessViolationException was unhandled
  HResult=-2147467261
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=ERPConnect40
  StackTrace:
       at ERPConnect.RFCAPI.RfcCallReceiveExt(Int32 handle, Int32 hSpace, String FuncName, StringBuilder Exception)
       at ERPConnect.R3Connection.Ping()
       at ERPConnect.Linq.ERPDataContext.Dispose(Boolean disposing)
       at ERPConnect.Linq.ERPDataContext.Dispose()

注意:代码没有问题,因为它是安静的旧代码并且在我以前的机器(Windows 7 + VS 2012)上运行良好,现在我有 windows 8.1.

我已经试过了:

请帮忙。

我在尝试使用 connection.CreateFunction() 方法使用标准 BAPI 函数时遇到了同样的问题。它似乎也是随机发生的。

RFCFunction funcModify = _r3Connection.CreateFunction("BAPI_ALM_NOTIF_DATA_MODIFY");
                funcModify.Exports["NUMBER"].ParamValue = notifNo.PadLeft(12,'0');

我已经 post 使用 theobald 软件(ERPconnect 的所有者)签了票。如果我设法开始工作,post 有什么有用的信息吗?

就我而言,问题与 librfc32.dllSystemWow 文件夹中丢失有关,我通过将两个 librfc dll:一个用于 32 位,另一个用于 64 位 Windows/Systems 文件夹中。

我参考了下面的内容link,其中包含有关库位置和 dll 的必需信息:

https://my.theobald-software.com/index.php?/Knowledgebase/Article/View/71/9/theobald--products-in-a-64-bit-environment

希望这对其他人有帮助。