目前,我在我的 Mac 上运行了一项服务,该服务是用 C# 编写的,位于usr/local/program
. 该服务能够通过根据服务器版本号检查版本号来检测何时需要更新。更新方法会运行,但是当它尝试下载update.xml
包含信息和要下载的文件的文件时总是会出现异常。这是我们从自定义记录器中获得的异常:
11:09:46 AM [Debug] Exception Type: WebException
11:09:46 AM [Debug] Stack Trace for above:
at System.Net.WebClient.DownloadFile (System.Uri address, System.String fileName) [0x00000] in <filename unknown>:0
at System.Net.WebClient.DownloadFile (System.String address, System.String fileName) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Net.WebClient:DownloadFile (string,string)
at dabler.Client.ClientService.tryUpdate () [0x00000] in <filename unknown>:0
11:09:46 AM [Debug] System.NotSupportedException: http://www.website.com/updates/client/update.xml
at System.Net.WebRequest.GetCreator (System.String prefix) [0x00000] in <filename unknown>:0
at System.Net.WebRequest.Create (System.Uri requestUri) [0x00000] in <filename unknown>:0
at System.Net.WebClient.GetWebRequest (System.Uri address) [0x00000] in <filename unknown>:0
at System.Net.WebClient.SetupRequest (System.Uri uri) [0x00000] in <filename unknown>:0
at System.Net.WebClient.DownloadFileCore (System.Uri address, System.String fileName, System.Object userToken) [0x00000] in <filename unknown>:0
at System.Net.WebClient.DownloadFile (System.Uri address, System.String fileName) [0x00000] in <filename unknown>:0
我对此进行了研究,根据我发现的文档,NotSupportedException 表示“该方法已在多个线程上同时调用”。但是,这是该服务第一次尝试下载文件,所以我不明白这是怎么发生的。我想到的一种可能性是它正在尝试将文件下载到,usr/local/program/update.xml
但我授予程序根访问该文件夹的权限。