不允许使用xmlSerializer'tempFilesLocation'属性.NET 3.5 - 显示默认的TEMP位置 [英] xmlSerializer 'tempFilesLocation' attribute is not allowed .NET 3.5 - showing default TEMP location

查看:205
本文介绍了不允许使用xmlSerializer'tempFilesLocation'属性.NET 3.5 - 显示默认的TEMP位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更改从soap请求(Web服务)调用信息时创建临时文件的目录,因为对我们的系统管理员来说,访问Windows目录是禁止的。

I am changing the directory that the temp files are created in when calling information from a soap request (web service) as giving access to windows directories is a no-no per our sys admins.

我已将以下内容添加到我的web.config中:

I've added the following to my web.config:

  <system.xml.serialization>
    <xmlSerializer tempFilesLocation="C:\\foo" />
  </system.xml.serialization>

我在VS2010中使用.NET 2.0和C#

I am working in VS2010 with .NET 2.0 and C#

我的web.config给了我一个警告,即不允许'tempFilesLocation'属性。但是根据这里的一些教程和其他问题 - 无论如何我继续 - 它说C:\ foo没有权限,但是它识别了更改 - 所以我在应用程序目录中创建了一个临时目录并将web.config更新为指向我的适当的目录:

My web.config gives me a warning that the 'tempFilesLocation' attribute is not allowed. But per some tutorials and other questions here - I proceeded anyway - it says that C:\foo doesn't have permissions, but it's recognizing the change - so I created a temp directory in the application directory and updated the web.config to point to my appropriate directory:

<xmlSerializer tempFilesLocation="c:\\inetpub\wwwroot\myapplicationdirectory\temp"/>

然后当我运行debug(或build-> publish)时,我收到以下错误:

Then when I run debug (or build->publish) I get the following error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\Windows\TEMP\z7z7l54i.0.cs' could not be found
error CS2008: No inputs specified

  at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
  at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
  at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
  at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Evidence evidence)
  at System.Web.Services.Protocols.SoapServerType..ctor(Type type, WebServiceProtocols protocolsSupported)
  at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
  --- End of inner exception stack trace ---
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.ServiceModel.FaultException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\Windows\TEMP\z7z7l54i.0.cs' could not be found
error CS2008: No inputs specified

如何更改,以便不再尝试访问C:\ Windows \\\\\我认为这是对web.config的补充吗?

How do I change so it's no longer trying to access the C:\Windows\TEMP directory? I thought that's what the addition to web.config did?

我正在尝试将目录更改为其他地方我可以根据需要提供适当的级别访问权限来创建这些临时值文件。

I'm trying to change the directory to somewhere else I can give appropriate level access as needed to create those temp files.

推荐答案

通常,当您创建Web / Web服务应用程序时,权限是
正确设置。例如,Web应用程序的临时文件保存在

Normally when you create a web/web service application the permissions are set correctly. For Example the temporary files for web apps are held in


C:\ Windows \ Mesrosoft.NET \ Framework {empty或64 } \ {.net
version} \Temporary ASP.NET Files。

C:\Windows\Microsoft.NET\Framework{empty or 64}\{.net version}\Temporary ASP.NET Files.

还取决于IIS应用程序的方式池已设置为使用该文件夹需要具有写访问权限。如果它是默认值,那么它是IIS_IUSRS组或帐户IUSR。

Also depending on how the IIS app pool is set up that use would need to have write access to the folder. If it's the default, then its the group IIS_IUSRS or account IUSR.

还要看这个回答需要为c:\windows \ temp文件夹设置权限。

Also look at this answer the permissions need to be set for the c:\windows\temp folder.

这篇关于不允许使用xmlSerializer'tempFilesLocation'属性.NET 3.5 - 显示默认的TEMP位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆