我正在更改從soap請求(Web服務)調用信息時創建臨時文件的目錄,因爲它允許訪問Windows目錄是no-no根據我們的系統管理員。不允許使用xmlSerializer'tempFilesLocation'屬性.NET 3.5 - 顯示默認TEMP位置
我已經添加了以下到我的web.config:
<system.xml.serialization>
<xmlSerializer tempFilesLocation="C:\\foo" />
</system.xml.serialization>
我在VS2010的工作與.NET 2.0和C#
我的web.config給我一個警告,「tempFilesLocation '屬性是不允許的。但是,在這裏有一些教程和其他問題 - 無論如何我繼續 - 它說C:\ foo沒有權限,但是它承認更改 - 所以我在應用程序目錄中創建了一個臨時目錄並更新了web.config以指向我適當的目錄:
<xmlSerializer tempFilesLocation="c:\\inetpub\wwwroot\myapplicationdirectory\temp"/>
後來,當我運行調試(或建設 - >發佈),我收到以下錯誤:
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 \ TEMP目錄?我認爲這是web.config的附加功能嗎?
我想改變目錄到別的地方我可以根據需要給予適當的級別訪問來創建這些臨時文件。
是的,我試圖找到一個解決方案,不涉及更改訪問臨時目錄(如這裏:http://www.hanselman.com/blog/ChangingWhereXmlSerializerOutputsTemporaryAssemblies.aspx),因爲我們的系統管理員有已經表示他們不想更改Windows目錄中的任何內容的權限。 – Hanny
你可能在和.NET以及Windows打架。我認爲這是任何微軟的傾銷領域。我首先允許訪問並查看它是否有效。另外,當您運行Visual Studio時,請確保以管理員模式運行它。 – Geek
Drats。我給每個人訪問'C:\ Windows \ Temp'(包括讀/寫),但仍然看到錯誤,指出'C:\ Windows \ TEMP \ somename.cs'找不到 - 所以我猜可能還有別的東西愚蠢可能會進一步深入,我沒有得到。我感謝你看看! – Hanny