gpt4 book ai didi

c# - OpenXML、IsolatedStorage、网络服务和 Windows Server 2008

转载 作者:太空狗 更新时间:2023-10-30 01:25:33 24 4
gpt4 key购买 nike

我有一个大型网络应用程序。此 Web 应用程序的一小部分使用 OpenXML 库(用 C# 编写)生成 XLSX 文件。

我遇到了这篇文章中描述的问题:IsolatedStorage Access Denied

但是,Windows Server 2003 的说明和 2008 中的用户目录层次结构不同。

我尝试在这些位置创建 IsolatedStorage 目录(然后向其授予 NETWORK SERVICE 权限):

C:\Users\Default\AppData\Local\IsolatedStorageC:\Users\Default\AppData\Roaming\IsolatedStorage

那些没有用。我试图找到 IsolatedStorage 目录在 Windows Server 2008 上的适当位置(通常使用 Google,特别是此处),但没有成功。

谁能告诉我应该在哪里创建该目录(或者建议一些其他解决方案,强制 OpenXML 指示存档库不使用 IsolatedStorage 创建电子表格)?

编辑 - 2011 年 7 月 14 日 - 添加异常消息和堆栈跟踪,希望能帮助其他人找到它。

Exception: System.ApplicationException
Message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Source: mscorlib
at System.IO.IsolatedStorage.IsolatedStorageFile.nGetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder..ctor()
at MS.Internal.IO.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile()
at MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName)
at MS.Internal.IO.Packaging.SparseMemoryStream.EnsureIsolatedStoreStream()
at MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary()
at MS.Internal.IO.Zip.ZipIOFileItemStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Compression.DeflateStream.InternalWrite(Byte[] array, Int32 offset, Int32 count, Boolean isAsync)
at System.IO.Compression.DeflateStream.Write(Byte[] array, Int32 offset, Int32 count)
at MS.Internal.IO.Packaging.CompressStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Xml.XmlUtf8RawTextWriter.FlushBuffer()
at System.Xml.XmlUtf8RawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at DocumentFormat.OpenXml.OpenXmlElement.WriteAttributesTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.SaveToPart(OpenXmlPart openXmlPart)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.SavePartContents()
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose(Boolean disposing)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Close()

最佳答案

在我的研究过程中,我也偶然发现了这篇博文:http://www.kevinrohrbaugh.com/blog/tag/openxml

起初我拒绝了它,因为我无法让我的应用程序模拟另一个用户,因为它与我无法控制的另一个 Web 应用程序交互的方式。

但是,我开始思考,也许我去掉了 ProfileList 中 NETWORK SERVICE 的注册表项,我可以获得相同的结果。

因此,我将 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20 重命名为 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20-backup并重新运行我的 Excel 导出,它工作正常。据我所知,这样做没有任何负面结果。

关于c# - OpenXML、IsolatedStorage、网络服务和 Windows Server 2008,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6679193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com