Overcoming WinSCP Assembly Issues in BizTalk 2016

Recently I was having issues on BizTalk 2016 getting the SFTP adapter to work correctly. I had followed all of the steps listed at Michael Stephenson’s blog entry here, but I was still getting this error:

A message sent to adapter “SFTP” on send port “<send port name>” with URI “sftp://<port URI>” is suspended.
Error details: System.TypeLoadException: Could not load type “WinSCP.RemotePath” from assembly “WinSCPnet, Version=, Culture=neutral, PublicKeyToken=…”

I made sure nothing was GAC’ed and the correct version of the dll was in the BizTalk program files folder, but still I had this error.

I was able to add a reference to the dll that had this version in a project and in the object browser it showed that the RemotePath type did not exist in the dll file. I checked on Nuget for WinSCP but could not find a version that matched and had the RemotePath type in it.

Here is my solution:

  1. I downloaded the absolute latest version from the Nuget WinSCP site. When running Michael’s script it downloads an older version of the dll. I installed the absolute latest version and then copied the WinSCP.exe and WinSCPnet.dll files from the C:\Program Files (x86)\WinSCP folder to the BizTalk program files folder just like the script does. For me the files had version
  2. Then I added an assembly binding redirect to the BizTalk config files (what I added is between the dependentAssembly tags in purple):
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <probing privatePath="BizTalk Assemblies;Developer Tools;Tracking;Tracking\interop" />
        <assemblyIdentity name="WinSCPnet" publicKeyToken="2271ec4a3c56d0bf" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />


This binding redirect ensures that a version of the WinSCP code runs that has the RemotePath type when the version is invoked. It appears the BizTalk SFTP adapter was bound to this version but I could not find a version that had the RemotePath type.

I updated both the BTSNTSvc.exe.config and the BTSNTSvc64.exe.config files and restarted the host instances.

Note: I noticed that the BizTalk 2016 CU 7 updated its support for WinSCP to a newer version so after applying the cumulative update the BizTalk SFTP adapter will be referencing a new version of WinSCP so you may not need this any longer after CU 7.

Blog at WordPress.com.

Up ↑