WinSCPnet.dll 6.3 missingMethodExceptions : RemoteFileInfoCollection.GetEnumerator

Advertisement

r4v3n
Joined:
Posts:
11
Location:
Stockholm, Sweden

WinSCPnet.dll 6.3 missingMethodExceptions : RemoteFileInfoCollection.GetEnumerator

We have been using WinSCPnet.dll since long time with RemoteFileInfoCollection.GetEnumerator, but suddenly in latest 6.3 (1.15.0.14793) version this is not available anymore so our application crashes. Is this a known issue? Can you add this back in next version? I want to be able to continue to use the latest version in case there is some future security fix. Our customers download and use latest automation version with AssemblyRedirect without need of recompilations of all other applications.

If there is a breaking change in interface, please keep both the old and the new implementation and recommend to use the new implementation instead of removing existing interface causing breaking change.

WinSCP automation 6.1.2 (1.14.0.13797) still works fine so they change seems to be related to this :
https://github.com/winscp/winscp/commit/6f38e242d99e819b5bb394bd717345e9cf62a065

Here is the missing implementations (picture)

WinSCP-6.3.MissingMethodException-RemoteFileInfoCollection.GetEnumerator.png

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,538
Location:
Prague, Czechia

Re: WinSCPnet.dll 6.3 missingMethodExceptions : RemoteFileInfoCollection.GetEnumerator

Do I understand right that you are explicitly calling something like this?
session.ListDirectory(...).Files.GetEnumerator()

Reply with quote

r4v3n
Joined:
Posts:
11
Location:
Stockholm, Sweden

Unfortunately I have not been able to find exactly where exception is happening yet, as the code is Jitted in callbacks/new thread start when returning from polling start and crashing before logging, but there is no GetEnumerator direct call found anywhere in my searches, but indirectly via List and Dictionary objects when using foreach calls where information is stored about which files have been downloaded (yet to be deleted), which are pending (not downloaded yet), which already downloaded and deleted (duplicate check).

It is more related to these indirect IEnumerable operations where GetEnumerator is needed:

I tried to reproduce the issue a lot, but not possible. So I decided to recompile existing code where it fails and when decompiling the old code which is compiled against older version of WinSCP where GetEnumerator existed, it is then optimised and changed to use this instead, so .NET seems to prefer this during compilation (compiler usually try to use the fastest, best performant)
WinSCP.RemoteDirectoryInfo info1;
info1 = connection1.ListDirectory(FolderPath);
System.Collections.IEnumerator enumerator1 = info1.get_Files().GetEnumerator();
while (enumerator1.MoveNext())
 {
   WinSCP.RemoteFileInfo fileInfo1 = (WinSCP.RemoteFileInfo)enumerator1.Current;
Source:
RemoteDirectoryInfo fileList;
fileList = connection.ListDirectory(FolderPath);
foreach (RemoteFileInfo info in fileList.Files)
So best to keep this as all previously compiled code may use GetEnumerator. Many have old code which is hard to recompile so best to keep APIs compatible for quick simple update via AssemblyRedirect. Some may also use this directly if it is more optimised and was available.

Sample AssemblyRedirect used in .NET applications:
<runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
   <dependentAssembly>
     <assemblyIdentity name="WinSCPnet" publicKeyToken="2271ec4a3c56d0bf" culture="neutral" />
       <bindingRedirect oldVersion="1.0.0.0-1.65535.65535.65535" newVersion="1.15.0.14793"/> <!-- 6.3: 1.15.0.14793 6.1.2 = 1.14.0.13797 (winscpnet.dll version) -->
   </dependentAssembly>
 </assemblyBinding>
</runtime>

Reply with quote

r4v3n
Joined:
Posts:
11
Location:
Stockholm, Sweden

Re: WinSCPnet.dll 6.3 missingMethodExceptions : RemoteFileInfoCollection.GetEnumerator

Hello Martin,

Seems I found the issue. All previous code compiled with your older versions are optimized automatically to use the GetEnumerator instead. When testing with newly compiled code there is no issue. Problem is that many have older code that is not easily recompilable and our old version will not be possible most likely. So would be great to get this back in there to avoid compatibility issues.

Also since .NET is optimizing for this, it is probably the fastest implementation as well.

Thanks
Niklas

Reply with quote

martin
Site Admin
martin avatar

Re: WinSCPnet.dll 6.3 missingMethodExceptions : RemoteFileInfoCollection.GetEnumerator

Well, indeed, the implementation of GetEnumerator was previously at each of the collection class exposed by WinSCP .NET assembly API. In the last version that implementation was moved to a common parent class. That indeed breaks binary compatibility. But tbh, we never claimed that we keep binary compatibility. The code level API has not changed.

Reply with quote

Advertisement

You can post new topics in this forum