-3

When I test on my local computer, it's English.

When I deployed to web server located at HK\China, it's gibberish.

I already force the culture info into English, still the same.

I want to log exception in English no matter what, then show exception to user accordingly but not in gibberish.

Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
try
{
    ...
}
catch (SAP.Connector.RfcSystemException rfcSystemException)
{
    LogHandler.LogError(logger, "", rfcSystemException);
    ShowMessage("RfcSystemException", rfcSystemException.Message);
}

Message: Material XXX not maintained in plant YYY

Error Code: RFC_ERROR_SYSTEM_FAILURE

Source: SAP.Connector.Rfc

Stack trace:

at SAP.Connector.SAPConnection.ThrowRfcException(RFC_ERROR_INFO_EX rfcerrInfo, Encoding encoding, String languangeCode) at SAP.Connector.Rfc.RfcClient.RfcInvoke(SAPClient proxy, String method, Object[] methodParamsIn) at SAP.Connector.SAPClient.SAPInvoke(String method, Object[] methodParamsIn) at DrawingReq_BAPI.SAPProxy1.Zats_Create_Sourcelist(String Material, String Plant, String Purorg, String Valid_From, String Valid_To, String Vendor_Code) at ComparePrice.btnUpload_Click(Object sender, EventArgs e) in d:\TFS\XXX\ComparePrice.aspx.cs:line 688

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Pop
  • 525
  • 1
  • 7
  • 22

3 Answers3

0

It's probably not gibberish, it's probably Chinese.

As to exceptions, switching the thread CurrentUICulture will change the language the exceptions are generated in, but it does require that the language be installed on the operating system the program is running on.

You may be able to get this to work with using CultureInfo.InvariantCulture, which uses English for its string localization.

PMV
  • 2,058
  • 1
  • 10
  • 15
  • InvariantCulture is used but still gibberish. It's gibberish because I can read Chinese but not this gibberish. – Pop Oct 14 '16 at 05:57
0

I don't now what you define as gibberish but from what you describe it could be a problem with unicode/non-unicode.

You are using a TCP/IP-Connection with SM59, right? Could you do a Unicode Test on that connection?

lichtbringer
  • 120
  • 9
0

I was told to use SAP .Net Connector 3.0 to call those RFCs and the exception message caught display accordingly to the language set in connection string, no more gibberish.

Pop
  • 525
  • 1
  • 7
  • 22