SFTP sample crash with Mono 3.2.3

+1 vote
asked Oct 29, 2013 by sarevok (250 points)
edited Mar 3, 2014

Hello!

I am using RebexSftp 2013R2 Full. I was trying to run my code with MONO 3.2.3 on Centos 6.4. Unfortunately I received an error. Then I got the same errors with your SftpConsoleClient.exe sample:

mono SftpConsoleClient.exe
Unknown heap type: CLR

Unknown heap type: CLR

Unknown heap type: CLR

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for Rebex.EncodingTools ---> System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: count
  at System.Text.UnicodeEncoding.GetString (System.Byte[] bytes, Int32 index, Int32 count) [0x00000] in <filename unknown>:0
  at A.JG.B (Int32 A) [0x00000] in <filename unknown>:0
  at Rebex.EncodingTools..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Rebex.Net.Sftp..ctor () [0x00000] in <filename unknown>:0
  at Rebex.Samples.ConsoleClient.ConsoleClient..ctor () [0x00000] in <filename unknown>:0
  at Rebex.Samples.ConsoleClient.ConsoleClient.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for Rebex.EncodingTools ---> System.ArgumentOutOfRangeException: ArgRange_Array
Parameter name: count
  at System.Text.UnicodeEncoding.GetString (System.Byte[] bytes, Int32 index, Int32 count) [0x00000] in <filename unknown>:0
  at A.JG.B (Int32 A) [0x00000] in <filename unknown>:0
  at Rebex.EncodingTools..cctor () [0x00000] in <filename unknown>:0
  --- End of inner exception stack trace ---
  at Rebex.Net.Sftp..ctor () [0x00000] in <filename unknown>:0
  at Rebex.Samples.ConsoleClient.ConsoleClient..ctor () [0x00000] in <filename unknown>:0
  at Rebex.Samples.ConsoleClient.ConsoleClient.Main (System.String[] args) [0x00000] in <filename unknown>:0

You wrote on your site that this library should supports Mono 2.10 or later. Could you look at these errors? It would be great if you could provide a fix for this issue.

Best regards,

Staszek Jankowski

Applies to: Rebex SFTP

3 Answers

0 votes
answered Oct 29, 2013 by Lukas Pokorny (101,070 points)
edited Mar 3, 2014

UPDATE

Since 2014R1 our assemblies are made more obfuscator-friendly which should prevent the issue reported here.


Hello, we will look into this. We know for sure that our library works with Mono 3.2, so it's kind of strange it doesn't work with 3.2.3 for you.

However, we first have to determine what is actually causing the error. The stack trace is a great start - there is some problem in the EncodingTools object static constructor which is called by the Sftp object (which actually calls Rebex.EncodingTools.Default). Could you please try running the following code to make sure this is indeed the issue?

    var encoding = Rebex.EncodingTools.Default;

If this fails as well, please try declaring this class and call its GetDefault() method. Does it fail or does it work?

    public class StringArrayTest
    {
        private static Encoding _default;

        public static Encoding GetDefault()
        {
            if (_default == null)
                _default = Encoding.GetEncoding(EncodingNames[2]);

            return _default;
        }

        private static readonly string[] EncodingNames =
        {
            "windows-1250",
            "windows-1251",
            "windows-1252",
            "windows-1253",
            "windows-1254",
            "windows-1255",
            "windows-1256",
            "windows-1257",
            "windows-1258",
            "iso-8859-1",
            "iso-8859-2",
            "iso-8859-3",
            "iso-8859-4",
            "iso-8859-5",
            "iso-8859-6",
            "iso-8859-7",
            "iso-8859-8",
            "iso-8859-9",
            "iso-8859-11",
            "iso-8859-13",
            "iso-8859-15",
            "IBM437"
        };
    }
0 votes
answered Oct 30, 2013 by sarevok (250 points)
edited Oct 31, 2013

Hi!

The first code returns the same errors as in previous post. The second one works without any errors.

commented Oct 30, 2013 by Lukas Pokorny (101,070 points)
edited Oct 30, 2013

Thanks! Please try the following hotfix build and let me know whether it makes any difference. If it fails, please post a new stack trace.

commented Oct 31, 2013 by sarevok (250 points)
edited Oct 31, 2013

With this hotfix everything works for me. Thanks a lot! Can I use it in my main project? Or should I wait for the official release?

commented Oct 31, 2013 by Tomas Knopp (58,890 points)
edited Oct 31, 2013

You can use the hotfix in your main project much in the same way as you would use a major release. We are glad it works now - thank you for your original report!

commented Oct 31, 2013 by Lukas Pokorny (101,070 points)
edited Oct 31, 2013

Actually, this hotfix is a trial version that expires in 30 days. I just sent a link to a full version to your e-mail.

0 votes
answered Mar 3, 2014 by Tomas Knopp (58,890 points)
edited Mar 3, 2014

Since 2014R1 our assemblies are made more obfuscator-friendly which should prevent the issue reported here.

...