IIS7中的unable to generate a temporary class错误解决办法

来源:互联网 发布:古风的男生网络名4个字 编辑:程序博客网 时间:2024/05/14 17:05

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

错误信息
System.ServiceModel.CommunicationException was unhandled
  Message=There was an error in serializing bodyof message SearchRequest1: 'Unable to generate a temporaryclass (result=1).
error CS2001: Source file'C:\Windows\TEMP\s0phakvt.0.cs' could not befound
error CS2008: No inputs specified
'.  Please see InnerException for moredetails.
  Source=mscorlib
  StackTrace:
    Server stacktrace:
      atSystem.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriterwriter, MessageVersion version, String action, MessageDescriptionmessageDescription, Object returnValue, Object[] parameters,Boolean isRequest)
      atSystem.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriterwriter)
      atSystem.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriterwriter)
      atSystem.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriterwriter)
      atSystem.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Messagemessage, BufferManager bufferManager, Int32 initialOffset, Int32maxSizeQuota)
      atSystem.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Messagemessage, Int32 maxMessageSize, BufferManager bufferManager, Int32messageOffset)
      atSystem.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Messagemessage)
      at System.ServiceModel.Channels.HttpOutput.Send(TimeSpantimeout)
      atSystem.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.SendRequest(Messagemessage, TimeSpan timeout)
      at System.ServiceModel.Channels.RequestChannel.Request(Messagemessage, TimeSpan timeout)
      at System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway, ProxyOperationRuntime operation, Object[] ins,Object[] outs, TimeSpan timeout)
      atSystem.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessagemethodCall, ProxyOperationRuntime operation)
      at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessagemessage)

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

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

右键C盘windows temp 文件夹权限增加 network Service 或者 everyone 权限设置为增删改查
原创粉丝点击