错误:无法生成临时类(结果=1)...在 Web 服务上调用方法时。我正在使用 VS 2008 C# ASP.NET 3.5。我正在为我的应用程序调用远程网络服务。
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
文件夹。选择属性,然后在安全选项卡中添加与您的网络服务应用程序池关联的帐户。点击确定 按钮,转到 IIS 并回收您的应用程序池。这应该可以解决您的 Web 服务请求。
值得注意的是,围绕此错误的情况可能具有欺骗性。 5 年来我遇到过这个问题几次。 (我每次都忘记了。)它不那么引人注目的原因是因为你可以发布一个网络服务,成功浏览到相关的 asmx
页面并查看你的网络服务方法的大纲.此外,您的 Visual Studio 项目可以添加对 Web 服务的引用,Visual Studio 将自动为您的 VS 项目中的 Web 服务生成所有关联的类。
这给人的印象是一切正常,直到您发出第一个请求以在 Web 服务上执行方法。 Web 服务在开始执行代码时会失败,因为它需要访问 temp
目录。
有关此错误的更多信息可以在已确认的 bug report 中找到在 Microsoft.com。
关于c# - 错误 : Unable to generate a temporary class (result=1) . .. 在 Web 服务上调用方法时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8061578/