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

时间:2011-11-09 07:20:50

标签: c# asp.net web-services .net-framework-version

错误:无法生成临时类(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

2 个答案:

答案 0 :(得分:36)

首先,信用到期的信用。 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上的已确认bug report

答案 1 :(得分:0)

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