使用 WinSCP .NET 程序集时,...\WinSCP.exe 的版本与该程序集的版本不匹配

The version of ...\WinSCP.exe does not match version of this assembly when using WinSCP .NET assemly

我正在使用一个名为 WinSCPnet.dll 的库。仅当我将 AssemblyFileVersion 设置为与安装它的 WinSCP.exe 相同的版本时,该代码才有效。

我遇到了这个异常:

The version of C:\Program Files (x86l\WinSCP\WinSCP.exe (5.15.1.0) does not match version of this assembly C:\Users\burkarty\source\repos\UAReport3\UAReport3\bin\Debug\UAReport3.exe (0.0.0.0).

如何 运行 我的代码独立于 WinSCP 版本?

我搜索了一个类似的问题,但对我没有任何帮助。

您不应依赖 已安装的 WinSCP 版本

您的应用程序应部署自己的 WinSCP.exe 副本,WinSCPnet.dll 的应用程序版本与之兼容。理想情况下,使用 WinSCP NuGet package,它可以解决这个问题。

有关其他选项,请参阅 WinSCP .NET assembly installation and deployment instructions