错误:无法生成临时类(result = 1)…在Web服务上调用方法时

错误:无法生成临时类(result = 1)…在Web服务上调用方法时。 我正在使用VS 2008 C#ASP.NET 3.5。 我正在为我的应用程序调用远程Web服务。

Server Error in '/' Application. Server was unable to process request. ---> Unable to generate a temporary class (result=1). error CS2001: Source file 'C:\WINDOWS\TEMP\6sbkwt2d.0.cs' could not be found error CS2008: No inputs specified Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Unable to generate a temporary class (result=1). error CS2001: Source file 'C:\WINDOWS\TEMP\6sbkwt2d.0.cs' could not be found error CS2008: No inputs specified Source Error: Line 775: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/CheckLogin", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] Line 776: public System.Data.DataSet CheckLogin(string uname, string pswd) { Line 777: object[] results = this.Invoke("CheckLogin", new object[] { Line 778: uname, Line 779: pswd}); Source File: c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\14127ae4\96323535\App_WebReferences.u9ldrmk1.0.cs Line: 777 

首先,信贷到期的信贷。 OP解决了这个问题,并在问题的评论部分回答了这个问题。 但是,据我所知,很多人来到StackOverflow并会阅读这个问题,而不是看评论。 因此,我在这里转发上述答案。 如果这是有用的,请务必向上投票。

出现此问题的原因是与IIS中的Web服务的应用程序池关联的帐户没有对C:\Windows\Temp文件夹的读/写权限。 我不知道为什么帐户需要访问此文件夹,但确实如此。 从我的偶然观察来看,它看起来只是将一个带有随机名称的空文件写入Temp文件夹。

要解决此问题,请浏览到C:\Windows文件夹,然后右键单击Temp文件夹。 选择“ 属性” ,然后在“ 安全”选项卡上添加与Web服务应用程序池关联的帐户。 单击确定按钮,转到IIS并回收您的应用程序池。 这应该可以修复您的Web服务请求。

值得注意的是,围绕此错误的情况可能有点具有欺骗性。 我在5年内遇到过这个问题几次。 (我每次都忘记它。)之所以不那么明显是因为你可以发布一个Web服务,成功浏览到相关的asmx页面并查看你的web服务方法的大纲。 此外,Visual Studio项目可以添加对Web Service的引用,Visual Studio将自动生成VS项目中Web服务的所有关联类。

这给人的印象是,在您首次请求在Web服务上执行方法之前,一切正常。 Web服务在开始执行代码时将失败,因为它需要访问temp目录。

有关此错误的更多信息,请访问Microsoft.com上的确认错误报告 。

当您的网站无法使用应用程序池“DefaultAppPool”并且您选择了自己的池时,就会发生这种情况。 在这种情况下,您需要添加具有池名称的用户。

Resumenenespañol:Es necesario establecer permisos de escritura a la carpeta“C:\ Windows \ Temp”al usuario del grupo de aplicaciones。 Para esto,debes调查cual grupo deaplicacionesestásutilizandoycuálesdicho usuario,en mi caso era“servicio de red”,pero puede variar dependiendo detuconfiguración。 Luego de hacer esto,“recicla”el grupo de aplicaciones e intenta de nuevo。 EstaSoliciónfuncionóenWindows Server 2003 Saludos