gpt4 book ai didi

c# - 如何克服异常 "The Type Initializer for "SAP.Middleware.Connector.RfcConfigParameters"引发异常 - 错误# :-2146233036"

转载 作者:行者123 更新时间:2023-11-30 17:05:41 32 4
gpt4 key购买 nike

我们的应用程序通过 DCOM SAP 连接器从 SAP 系统获取数据。最近我们用 .NET 连接器代替了。部署到生产环境后,它工作了一天。在访问一个 RFC 时突然出现指定的错误。异常信息是

The Type Initializer for "SAP.Middleware.Connector.RfcConfigParameters" threw an exception - Error#:-2146233036.

我们为 SAP.Middleware.Connector.RfcConfigParameters 创建对象并使用的代码如下

string Value1 ="Val1";
string Value1 ="Val2";
string Value1 ="Val3";
string Value1 ="Val4";
string Value1 ="Val5";
string Value1 ="Val6";
string Value1 ="Val7";

RfcConfigParameters parms = new RfcConfigParameters();

parms.Add(RfcConfigParameters.Param1, Value1);
parms.Add(RfcConfigParameters.Param2, Value2);
parms.Add(RfcConfigParameters.Param3, Value3);
parms.Add(RfcConfigParameters.Param4, Value4);
parms.Add(RfcConfigParameters.Param5, Value5);
parms.Add(RfcConfigParameters.Param6, Value6);
parms.Add(RfcConfigParameters.Param7, Value7);

SapRfcDestination = RfcDestinationManager.GetDestination(parms);
RfcCustomDestination customDest = SapRfcDestination.CreateCustomDestination();
IRfcFunction func = customDest.Repository.CreateFunction("RFC_FUNCTION");

func.SetValue("DATA1", "VAL1")
func.SetValue("DATA2", "VAL2")
func.SetValue("DATA3", "VAL3")

RfcStructureMetadata metaData = customDest.Repository.GetStructureMetadata("STRUCTURENAME");
IRfcTable rfcTable = func.GetTable("TABLENAME");

我们已经追踪到了异常信息,下面是异常信息

System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load.
---> System.IO.FileLoadException: Could not load file or assembly 'msvcm80, Version=8.0.50727.6195, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
File name: 'msvcm80, Version=8.0.50727.6195, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at <CrtImplementationDetails>.DoDllLanguageSupportValidation()
at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )


--- End of inner exception stack trace ---
at <CrtImplementationDetails>.ThrowModuleLoadException(String errorMessage, Exception innerException)
at <CrtImplementationDetails>.ThrowModuleLoadException(String , Exception )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
--- End of inner exception stack trace ---
at SAP.Middleware.Connector.RfcConfigParameters..cctor()- Stack trace: at SAP.Middleware.Connector.RfcConfigParameters..ctor()

以下是我们的观察
1.它不是总是抛出问题。问题是间歇性抛出。
2. 当我们转到服务器机器并在那里运行应用程序时,它不会抛出错误。仅当应用程序从其他客户端机器访问时才会抛出错误。
3. 相同问题在开发、测试和阶段环境中不可重现。仅生产中的问题4. 如果我们重新部署特定的 dll,它将在一天或半天没有任何错误的情况下开始工作,第二天开始抛出错误。

我的具体问题是(1) 如何克服“The Type Initializer for "SAP.Middleware.Connector.RfcConfigParameters"throw an exception - Error#:-2146233036"的异常?
(2) 我们的主要怀疑区域是内存泄漏。我们可以怀疑任何其他领域吗?
(3) 我们对生产环境的访问非常有限,甚至无法访问。因此,我们正试图在我们拥有完全访问权限(如开发和测试)的其他服务器中重现该问题。我们正在考虑多用户和多登录场景,以便在其他环境中重现该问题。我们可以考虑任何其他情况吗?

更新
我们设法在我们的一个测试服务器中重现了这个问题。并尝试通过以下方式解决问题。并安装了 Visual C++ 2005 Redistributable SP1、.NET connector 3.0 和 VB6.0。仍然存在问题。我们无法找到问题的根本原因。

为了找到问题的根本原因,我还可以检查和做什么?

根据回复进行编辑:
1.我们没有使用任何静态变量2. 我们已经安装了Visual C++ 2005 Redistributable SP1,但还是没有解决问题。

最佳答案

This thread建议安装 Visual C++ 2005 Redistributable SP1 包解决它。 (由于对 sapnco_utils.dll 的依赖)

关于c# - 如何克服异常 "The Type Initializer for "SAP.Middleware.Connector.RfcConfigParameters"引发异常 - 错误# :-2146233036",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16210505/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com