+2 votes
by (180 points)

Hello,
I'm trying to use Rebex in a Xamarin Forms solution. I bought your SFTP library and try yet to use it in my Test solution.

I'm using VS 2015, 4 projects are present in my solution named "TestXamarinForms":
- TestXamarinForms (Portable)
- TestXamarinForms.Droid
- TestXamarinForms.iOS
- TestXamarinForms.WinPhone

Currently, I'm only testin on a Windows Phone device, so WinPhone project is set as startup project.

I added following references to "TestXamarinForms (Portable)" project:

  • net-4.0 : Rebex.Common.dll
  • net-4.0 : Rebex.Networking.dll
  • net-4.0 : Rebex.Sftp.dll

The solution compiles correctly and starts on the phone, but when the software tries to create a Rebex.Sftp object, here is the exception it raises:

An exception of type 'System.TypeLoadException' occurred in
TestXamarinForms.DLL but was not handled in user code Additional
information: Could not load type 'System.ICloneable' from assembly
'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e'.

Can you please help me resolve that problem?

Are the project references the right ones for Windows Phone 8.1?

Thank you in advance for your support.

Greetings

J-D Gasser

Applies to: Rebex SFTP

2 Answers

0 votes
by (147k points)

The "net-4.0" DLLs target .NET Framework 4.0, 4.5.x on Windows and Mono on Unix and OS/X. They don't work on other platforms.

Although Windows Phone 8.1 is not officially supported at the moment, we offer a beta of most Rebex components for Windows Store 8, 8.1 and Windows Phone 8.1 at Rebex labs.

However, please note that none of our components are available as Portable Class Libraries (PCL) due to the limitations set by the target platforms that are beyond our control.

by (180 points)
Hello Lukas,
Thank you for your quick answer.

I understand Windows Phone 8.1 is not officially supported, so thank you very much for giving me support about it.

After reading your answer, I tried to create a solution for Windows Phone only (.NET Framework 4.5.3) and it works. So the beta release is OK for Windows Phone project alone in solution.

Knowing that, I created a new Shared Assed Project (SAP) Xamarin Solution. As there is no PCL, only code is shared between platforms projects, this should be the same as a Windows Phone alone solution.

References added to my Windows Phone project are "Portable Class Library for Universal Apps".

I can compile and run on Android, but when I try to compile the Windows Phone project of the solution, here is the error on build process:
App.xaml(1,1,1,1): error : Cannot resolve dependency to assembly 'System.Runtime.InteropServices, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.

Do you think there is a solution?

Thank you in advance for your support.
by (147k points)
I don't think we actually tried using the beta DLLs in Xamarin's Shared Asset Projects (only tried various kinds of Visual Studio's Store Apps projects). We will give it a try on Monday and try to reproduce the issue and find a solution.
by (147k points)
0 votes
by (147k points)
edited by

We have been able to reproduce the issue with Visual Studio 2013. It looks like Xamarin Forms did not support "Windows Phone 8.1" targets until recently (see this and this). Our PCL libraries target "Windows 8.1" and "Windows Phone 8.1" and are not compatible with "Windows Phone Silverlight 8.0" and "Windows Phone Silverlight 8.1".

And even though TestXamarinForms.WinPhone project configuration seems to make it possible to change the target Windows Phone OS version to "Windows Phone 8.1", it actually changes the target to "Windows Phone Silverlight 8.1" instead (which our PCL libraries don't support).

However, the latest preview of Xamarin Forms should actually support "Windows Phone 8.1". Please upgrade Xamarin Forms and try creating a project for "Windows Phone 8.1" (as seen here). Does this solve the issue?

by (180 points)
Hello Lukas,
First of all thank you for the support, since two month I'm back working on that project.
I followed the instructions given by Xamarin in order to add a Windows Phone 8.1 project in my solution and I can now compile and run my code.

The problem now is when the program connects to the SFTP server. The software crashes without any exception when it makes a call to "ConnectAsync" of the Sftp object.

Can you please help me diagnose the origin of the crash?

Or do you have a sample solution using SFTP with Xamarin on Windows Phone 8.1 I can download in order to make some tests?

Thank you in advance.

Greetings

J-D Gasser
by (58.9k points)
Hello,

we have tried to create a Shared Xamarin.Forms Windows Phone 8.1 project. But we actually did not get past the error that you previously reported (Cannot resolve dependency to assembly 'System.Runtime.InteropServices, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a').

Could you please either point us to a direction how to solve this error, or send us a sample project that we could try to reproduce the error in ConnectAsync method? Thank you for your cooperation!

We are using the latest Xamarin version. We thought that we will first ask you as you already are ahead of us.

Actually, we at least tested the plain WP8.1 project and there the ConnectAsync method works without problems.
by (180 points)
Hello,
Sorry for the late answer, but I actually work on another time consuming project.

I can send you the Solution I'm working with so you can debug the SFTP part.
How can I send it to your support team ?

Greetings

J-D Gasser
by (58.9k points)
Hello,

this would be great! Just zip the project and send it to support@rebex.net. I will look into it then.

Thank you
by (58.9k points)
edited by
Hello,

actually, we were able to succesfully connect and login on both an WP8.1 simulator and an actual device via the ConnectAsync and LoginAsync methods with your Xamarin.Forms project (thanks for sharing it with us!).

However, I have noticed that your program does not show the exception into the UI in case the Task.IsFaulted property is set to 'true'. Are you sure that the ConnectAsync method really failed with no exception?

I am sending you back the project with improved exception handling via email, please give it a try and let me know whether you can see any Exception now in the ConnectAsync method with it.

Another option would be to check your generated log file. Is there any exception in the log when the ConnectAsync method fails?
...