0

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.

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

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

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

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"/>

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

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.

Hanny
  • 580
  • 3
  • 16
  • 44

1 Answers1

0

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\Microsoft.NET\Framework{empty or 64}\{.net version}\Temporary ASP.NET Files.

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.

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

Community
  • 1
  • 1
Geek
  • 415
  • 4
  • 16
  • Yeah, I'm trying to find a solution that doesn't involve changing access on the temp directory (such as here:http://www.hanselman.com/blog/ChangingWhereXmlSerializerOutputsTemporaryAssemblies.aspx) because our system admins have already said they don't want to change the permissions on anything in the Windows directory. – Hanny Aug 18 '16 at 13:43
  • You might be fighting against .Net there and Windows in general. I think that this is the dumping area for anything Microsoft. I would first allow the access and see if it it works. Also, when you run your Visual Studio ensure you run it in Administrator mode. – Geek Aug 18 '16 at 14:38
  • Drats. I gave everyone access to 'C:\Windows\Temp' (including read/write) but still see the error stating that 'C:\Windows\TEMP\somename.cs' cannot be found - so I'm guessing maybe something else silly might be going on deeper in this that I'm not getting. I appreciate you taking a look! – Hanny Aug 18 '16 at 15:52