我在Windows服务中运行WCF。该服务启动并运行正常,我可以访问该服务并从同一台机器调用WCF方法(使用LocalHost作为wcf服务器名称),但在最近的更改后,当我尝试从另一个调用其中一个WCF方法时工作站我收到System.IO.FileNotFoundException和WCF服务崩溃。在此之前它运作良好。
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的详细信息。
答案 0 :(得分:1)
我们发现有助于确定WCF服务主机启动问题(例如FileNotFoundException
)的根本原因的一种方法是启用WCF跟踪。通常,WCF跟踪日志将揭示以前“隐藏”的问题。
http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx