如何解决新 NWRfcSession() System.OutOfMemoryException
我正在制作一个使用 Rfc Connector 的方法。它工作正常,但出了点问题,现在我遇到了这两个问题。
-
有时(这不是规则)我从
OutOfMemoryException
得到Session = new NWRfcSession();
。我认为没有任何理由(没有大数据)。
有人可以帮我吗?我使用的是 VS 16.8.3 和 .NET 5.0。非常感谢!
public class RFCMethodsForSLS
{
private NWRfcSession Session;
//Info: https://rfcconnector.com/documentation/api/session/
public bool WasConnected { get; private set; }
public bool ResultWasNull { get; private set; }
private DataContext dataContext;
private List<Regex> listOfRegexFromDatabase;
public Exception Exception { get; private set; }
/// <summary>
/// Calls the "Connecting" method which returns wanted project entries from SAP
/// </summary>
/// <param name="inputString">String which will be searched</param>
/// <param name="onlyIn4711">True for entries active in only in OEZ</param>
/// <param name="onlyActive">True for active entries</param>
/// <param name="maxRows">Set maximum returned rows count</param>
public RFCMethodsForSLS()
{
try
{
Session = new NWRfcSession();
}
catch (Exception e) when (e is System.OutOfMemoryException) //when the connection is not possible
{
Exception = e; //if the connection is impossible then set Exception property
}
if (Exception is null)
{
dataContext = new DataContext();
listOfRegexFromDatabase = new List<Regex>();
foreach (MLFBCodeGroups mLFBCodeGroups in dataContext.MLFBCodesGroups.ToList())
listOfRegexFromDatabase.Add(new Regex(mLFBCodeGroups.Regex));
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。