Is WinSCP.NET only supported for Windows Phone?
Hi,
I'm working on a Universal Windows Platform app that should do both uploads and downloads to external servers. It should run in a background thread. It should run on Windows 10 PCs, but as I don't yet have the right development machine, I'm doing the initial work on Windows 8, using Visual Studio 2015.
As options available for FTP-uploads in the standard Windows API are limited, I considered calling the WinSCP.NET assembly.
My solution contains, among others, two projects
1. My normal Javascript project for Windows 8
2. A separate C# project just meant as the interface to WinSCP.NET. I tried two versions, one for Windows 8, one for Universal Windows. This project contains:
2a. The WinSCP.NET assembly v5.9.2, as loaded by the NuGet package manager
2b. Currently a single C# class which is currently not much more than a copy of the example in the docs:
However this setup fails immediately because I get a compilation error at the field WinSCP.Session: "Reference to type IReflect claims it is defined in 'mscorlib', but it could not be found."
Indeed this interface is not defined in the associated Windows-classes, and checking this in the Windows API (https://learn.microsoft.com/en-us/dotnet/api/system.reflection.ireflect) tells me that it is only supported for Windows Phone.
Obviously, this is quite fundamental, so it looks like this approach isn't an option in my case, and hacking the source of the WinSCP.NET assembly isn't a valid option as well as my experience with C# is almost zero. WinSCP.NET is the only reason I started using it.
But to me it seems strange that you can use the tool for a phone but not on a PC, so I before I continue my search for alternatives I want to make sure that I'm not missing something.
I'm working on a Universal Windows Platform app that should do both uploads and downloads to external servers. It should run in a background thread. It should run on Windows 10 PCs, but as I don't yet have the right development machine, I'm doing the initial work on Windows 8, using Visual Studio 2015.
As options available for FTP-uploads in the standard Windows API are limited, I considered calling the WinSCP.NET assembly.
My solution contains, among others, two projects
1. My normal Javascript project for Windows 8
2. A separate C# project just meant as the interface to WinSCP.NET. I tried two versions, one for Windows 8, one for Universal Windows. This project contains:
2a. The WinSCP.NET assembly v5.9.2, as loaded by the NuGet package manager
2b. Currently a single C# class which is currently not much more than a copy of the example in the docs:
using System; using WinSCP; namespace WinSCPComponent { sealed public class Example { public static int Main() { try { // Setup session options SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Sftp, HostName = "example.com", UserName = "user", Password = "mypassword", SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" }; using (Session session = new Session()) { // Connect session.Open(sessionOptions); // Upload files TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; TransferOperationResult transferResult; transferResult = session.PutFiles(@"d:\toupload\*", "/home/user/", false, transferOptions); // Throw on any error transferResult.Check(); // Print results foreach (TransferEventArgs transfer in transferResult.Transfers) { //Console.WriteLine("Upload of {0} succeeded", transfer.FileName); } } return 0; } catch (Exception e) { //Console.WriteLine("Error: {0}", e); return 1; } } } }
However this setup fails immediately because I get a compilation error at the field WinSCP.Session: "Reference to type IReflect claims it is defined in 'mscorlib', but it could not be found."
Indeed this interface is not defined in the associated Windows-classes, and checking this in the Windows API (https://learn.microsoft.com/en-us/dotnet/api/system.reflection.ireflect) tells me that it is only supported for Windows Phone.
Obviously, this is quite fundamental, so it looks like this approach isn't an option in my case, and hacking the source of the WinSCP.NET assembly isn't a valid option as well as my experience with C# is almost zero. WinSCP.NET is the only reason I started using it.
But to me it seems strange that you can use the tool for a phone but not on a PC, so I before I continue my search for alternatives I want to make sure that I'm not missing something.