【问题标题】:How to overcome the exception "The Type Initializer for "SAP.Middleware.Connector.RfcConfigParameters" threw an exception - Error#:-2146233036"如何克服异常“SAP.Middleware.Connector.RfcConfigParameters 的类型初始化程序引发异常 - 错误#:-2146233036”
【发布时间】:2013-04-19 02:19:43
【问题描述】:

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

“SAP.Middleware.Connector.RfcConfigParameters”的类型初始化程序引发异常 - 错误#:-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) 如何克服“SAP.Middleware.Connector.RfcConfigParameters”的类型初始化程序引发异常 - Error#:-2146233036 的异常?
(2) 我们的主要怀疑领域是内存泄漏。我们可以怀疑任何其他领域吗?
(3)我们非常有限,无法访问生产环境。因此,我们正试图在我们拥有完全访问权限的其他服务器(如开发和测试)中重现该问题。我们正在考虑多用户和多登录场景,以便在其他环境中重现该问题。我们可以考虑任何其他情况吗?

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

为了找到问题的根本原因,我还可以检查和执行哪些操作?

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

【问题讨论】:

  • 请贴出SAP.Middleware.Connector.RfcConfigParameters类的静态构造函数的代码。
  • @Steven:我在这里提供了所有代码和异常日志。请帮忙

标签: c# sap-dotnet-connector


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    经过大量分析和深入研究,我们找到了解决此问题的方法。

    我们使用的是 SAP 3.0.4。当我们检查 3.0.9 的最新 SAP 连接器发行说明时,如下所述。

    改进:destination 配置异常 当未指定所需的配置参数时,例如SYSID,当 尝试通过负载平衡进行连接,抛出了一个非常低级别的异常, 尚不清楚为什么无法连接 已确立的。现在,有早期检查,如果出现配置问题, 描述性的 RfcConfigurationException 正在详细告知 配置问题。

    请在下面找到 SAP Connector 3.0.8 的摘录

    发行说明 3.0.8 * 修正:目标配置 通过修改配置更改目标的跟踪级别 目的地对该目的地的属性 TraceLevel 没有影响, 即使触发了配置更新事件。

    因此我们安装了最新的 SAP 连接器 3.0.10 并使用最新的 SAP 连接器 dll(sapnco.dll 和 sapnco_utils.dll)重建 dll。随着这些最新的 dll 问题得到解决。

    【讨论】:

      猜你喜欢
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      • 2016-03-27
      • 1970-01-01
      • 1970-01-01
      • 2017-05-18
      • 2013-05-15
      • 2013-11-08
      相关资源
      最近更新 更多