我運行WCF Windows服務中。該服務啓動並運行良好,我可以訪問該服務,並呼籲從同一臺機器,(使用localhost作爲WCF服務器名稱)的WCF方法,但最近改變後,當我嘗試調用從另一個WCF方法之一工作站我得到一個System.IO.FileNotFoundException和WCF服務崩潰。在此之前,它工作正常。WCF FileNotFoundException異常
在WCF服務器上的應用程序日誌中的錯誤如下圖所示:有沒有說明到底是哪個文件無法加載。
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2014-12-29T18:33:27.000Z" />
<EventRecordID>3292</EventRecordID>
<Channel>Application</Channel>
<Computer>LASAPPTEST.rose.portland.local</Computer>
<Security />
</System>
- <EventData>
<Data>Application: CoP.Enterprise.ServiceHost.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info:
System.IO.FileNotFoundException Stack: at CoP.LAS.LASServiceHostProcessManager.StartProcess() at
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext,
System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run
(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at
System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext,
System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()
</Data>
</EventData>
</Event>
想法?有沒有什麼方法可以調試,並找出下一步要走的路?它試圖加載什麼文件?
與@seymour提示,找到了答案:使用WCF跟蹤日誌功能 (添加下列的web.config/app.config)中
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "C:\LASServices\LAS\Logs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
和使用WCF跟蹤日誌查看器(SvcTraceViewer.exe ),讀取FileNotFoundException的詳細信息。
哦,不斷有用FNF例外,不告訴你什麼該死的文件沒有被發現。好吧,我懷疑兩件事情 - 無論是它試圖加載程序集,或者一個文件,該文件不存在或已被鎖定或無法被搜索的一個。那麼,你是否試圖在StartProcess中加載一個文件?如果是這樣,如果不存在,就停止這樣做。如果沒有,請打開熔合記錄器,看看是否有裝配負載問題。 – Will
WCF跟蹤日誌中的任何錯誤或其他相關信息。過去,我們已經注意到跟蹤文件中的服務啓動錯誤信息。 – Seymour
「,但經過最近的一次改變」你改變了什麼? – khlr