cms kentico

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在访问IIS7的网站时,可能会遇到Service Unavailable的错误,错误的原因当然可能会有很多种,因此需要使用Just-In-Time Debugger来go into到实际的内部错误。

错误信息
System.ServiceModel.CommunicationException was unhandled
  Message=There was an error in serializing body of message SearchRequest1: 'Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\Windows\TEMP\s0phakvt.0.cs' could not be found
error CS2008: No inputs specified
'.  Please see InnerException for more details.
  Source=mscorlib
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)
       at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)
       at System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message message, BufferManager bufferManager, Int32 initialOffset, Int32 maxSizeQuota)
       at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset)
       at System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message)
       at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

解决办法:
右键点击C:\Windows\TEMP 目录,选择 properties->security ,添加 MachineName\IIS_IUSRS 账户(将MachineName替换成实际的服务器名称),给予它Read、Write、List等权限。再重新访问这个ASP页面,问题应该能够得到解决。

原因分析:
应该是在你的ASP页面中,调用了别的Web Service/WCF Service,ASP.NET Web Service有时候会在处理WebMethods时使用到C:\Windows\TEMP文件夹,因此需要给IIS的相关账户赋予相应的权限。

posted on 2012-10-24 11:26  cms kentico  阅读(584)  评论(0编辑  收藏  举报