目前,我有一个服务在我的Mac上运行,该服务以C#编写,位于usr/local/program
。通过对照服务器版本号检查版本号,此服务能够检测何时需要更新。运行update方法,但是在尝试下载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
但是我授予程序对该文件夹的root访问权限。
弄清楚了。它不起作用的原因是因为该程序是使用3.2.6构建的,而我试图在具有3.4.0的计算机上运行它。WebRequest.cs之间似乎没有什么区别,但是在较低版本中的构建绝对是问题所在。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句