wcf服务 ,在本地测试,远程部署都完全没问题。但是运行一段时间后WCF会出现错误,页面数据不显示了。
第一次出现的时候,立马想到是不是没有返回数据,抓包查看的时候,有json格式的数据返回。这怎么会不显示呢,对数据进行对比,发现其中部分数据有换行现象,于是将数据一条一条读取,读到有换行的数据是果然读不出来。处理了下一直运行至今毫无问题。
第二次另外一家客户也反映了这个问题,当时我还抱怨了说数据的时候咋不判断呀,告诉同事说,让他把显示数据过滤一遍,以为跟上回一样可以解决的。但是问题就来了,还是不能解决。我firebug看了下,提示找不到WCF服务。google了一番都是说WCF 配置问题。重新配置了一番,果然可以。正在沾沾自喜的时候,发现了一个问题,只是我打开.svc文件的那个服务好了,没有打开.svc文件的都不行,但是在config里都配置了。这就让我意识到不是配置问题了。
突然灵机一动看看系统日志会不会有提示。果然有,错误如下:
日志名称: Application 来源: System.ServiceModel 4.0.0.0 日期: 2013/9/23 9:57:47 事件 ID: 3 任务类别: (5) 级别: 错误 关键字: 经典 用户: NETWORK SERVICE 计算机: qyyngp 说明: WebHost failed to process a request. Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/37175364 Exception: System.ServiceModel.ServiceActivationException: The service '/DataService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'App_Web_ljypiyuh, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 系统找不到指定的文件。. ---> System.IO.FileNotFoundException: Could not load file or assembly 'App_Web_ljypiyuh, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 系统找不到指定的文件。 at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) --- End of inner exception stack trace --- at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath) Process Name: w3wp Process ID: 5620事件 Xml: <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> <System> <Provider Name="System.ServiceModel 4.0.0.0" /> <EventID Qualifiers="49154">3</EventID> <Level>2</Level> <Task>5</Task> <Keywords>0x80000000000000</Keywords> <TimeCreated SystemTime="2013-09-23T01:57:47.000Z" /> <EventRecordID>8471</EventRecordID> <Channel>Application</Channel> <Computer>qyyngp</Computer> <Security UserID="S-1-5-20" /> </System> <EventData> <Data>System.ServiceModel.ServiceHostingEnvironment+HostingManager/37175364</Data> <Data>System.ServiceModel.ServiceActivationException: The service '/DataService.svc' cannot be activated due to an exception during compilation. The exception message is: Could not load file or assembly 'App_Web_ljypiyuh, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 系统找不到指定的文件。. ---> System.IO.FileNotFoundException: Could not load file or assembly 'App_Web_ljypiyuh, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 系统找不到指定的文件。 at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) --- End of inner exception stack trace --- at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath)</Data> <Data>w3wp</Data> <Data>5620</Data> </EventData> </Event>
跟虚拟目录有关,w3wp是什么,google了一把。
w3wp:在IIS(因特网信息服务器)与应用程序池相关联的一个进程,如果你有多个应用程序池,就会有对应的多个w3wp.exe的进程实例运行。
原来还是iis部署问题。根据相应问题找到解决方案如下:
将项目已应用程序的方式部署,而不是已网站形式部署。
部署之后对比当前网站形势部署。果然在之前的问题依旧,已应用程序部署的OK!!
这次不知道是彻底解决还是暂时性解决,记录下以备后用。期待该问题下次重现周期。。。。。。