網頁

Microsoft Biztalk 2020的SFTP功能找不到WinSCPnet.dll錯誤處理

Microsoft Biztalk 2020的SFTP功能找不到WinSCPnet.dll錯誤處理

Microsoft Biztalk是一套專注於B2B資料交換的平台軟體。除了大型B2B(例如:EDI、RosettaNet)之外,一般常見的檔案傳輸方式也是有支援,例如:FTP。我們有個SFTP的定時上傳檔案需求,一般可能寫個C# Console或PowerShell加上排程來處理。但Biztalk本身內建了許多Adapter,其中包含了SFTP Adapter,透過設定就能做到的事情,當然選擇Biztalk來做。

Biztalk 2020 WinSCPnet.dll not found issue

我們將舊版Biztalk上的一組設定原封不動移轉到新版Biztalk 2020之後,發現SFTP的上傳不正常,追查後發現以下日誌:

A message sent to adapter "SFTP" on send port "Send_Dell_DISCP_SFTP" with URI "sftp://xxx.xxx.xxx.xxx/%SourceFileName%" is suspended. 
 Error details: System.Exception: SFTP adapter requires WinSCP to be installed. Please refer http://go.microsoft.com/fwlink/?LinkID=730458&clcid=0x409 . ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.BizTalk.Adapter.Sftp\v4.0_3.0.1.0__31bf3856ad364e35\WinSCPnet.dll' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.BizTalk.Adapter.Sftp.SftpHelper.AssemblyResolver(Object sender, ResolveEventArgs args)
   --- End of inner exception stack trace ---

Server stack trace: 
   at Microsoft.BizTalk.Adapter.Sftp.SftpOutputChannel.Send(Message message, TimeSpan timeOut)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [5]: 
   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndSend(IAsyncResult result)

第一條線索:http://go.microsoft.com/fwlink/?LinkID=730458&clcid=0x409會導向Biztalk文件,文件內會引導你到WinSCP頁面去下載WinSCP。文件是Biztalk 2016會希望你安裝WinSCP 5.7.7版本。我的版本是Biztalk 2020而且剛好這台主機已經有安裝WinSCP軟體了,雖然是比較舊一些的版本,所以我決定升級至目前撰文當下最新的WinSCP 5.17版本。

單純安裝WinSCP的方式,對於Biztalk 2020的WinSCP錯誤無效。

第二條線索:file:///C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.BizTalk.Adapter.Sftp\v4.0_3.0.1.0__31bf3856ad364e35\WinSCPnet.dll是說他找不到此路徑下的WinSCPnet.dll

再找了一些文件後(1)(2)都發現,他們都是說將.NET assembly / COM library放置Biztalk的安裝目錄下。

將WinSCP Library複製到Biztalk 2020安裝目錄的方式無效。

那麼手動下WinSCP .NET assembly / COM library,將WinSCPnet.dll複製到Biztalk 2020錯誤訊息的目錄下。

終於,此方式在Biztalk 2020終於讓SFTP功能正常作業。

不確定什麼原因,以前舊版本的Biztalk我去找過,沒有找到WinSCPnet.dll也能正常使用。可能新版Biztalk也開始擁抱開源軟體,但可能是商用軟體的關係,預設沒有把WinSCPnet.dll安裝進來,只是等到使用出現錯誤才知道要去下載安裝WinSCPnet.dll,這有點怪異就是了。

沒有留言:

張貼留言

感謝您的留言,如果我的文章你喜歡或對你有幫助,按個「讚」或「分享」它,我會很高興的。