Unable to create the store directory. (Exception from HRESULT: 0x80131468)

一个ASP.NET的程序,使用了MS ReportViewer报告控件,在用该控件导出生成Excel文件时,先是提示行不能超过65535。 这个是由于Excel2003的行限制的原因。由于修改成用Excel2007格式导出,用这种方法导出时报了如下错误:

Unable to create the store directory. (Exception from HRESULT: 0x80131468) 
错误堆栈: at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope, StringHandleOnStack retRootDir)
at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(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.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 Microsoft.ReportingServices.Rendering.ExcelOpenXmlRenderer.XMLModel.XMLStreamsheetModel.WriteStreamToStream(Stream from, Stream to)
at Microsoft.ReportingServices.Rendering.ExcelOpenXmlRenderer.XMLModel.XMLStreamsheetModel.Cleanup()
at Microsoft.ReportingServices.Rendering.ExcelOpenXmlRenderer.OpenXmlGenerator.FinalizeWorksheet()
at Microsoft.ReportingServices.Rendering.ExcelOpenXmlRenderer.OpenXmlGenerator.SaveSpreadsheet(Stream outputStream, Stream backgroundImage, UInt16 backgroundImageWidth, UInt16 backgroundImageHeight)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, Hashtable& renderProperties, CreateAndRegisterStream createAndRegisterStream)

  搜索了个原因,说是当导出的文件比较大时(>10M)时,会使用IsolatedStore来保存临时生成的文件,但当前运行ASP.NET的站点用户(Network Service, win2003)没有像Administrator或其它自己新建的账户那样生成本地用户档案,类似于‘C:\Documents and Settings\Default User’这样的文件夹,又没有足够的权限来创建。所以就报了‘Unable to create the store directory’的错误。

  解决方法:

  1. 使用ASP.NET的用户模拟。在Web.Config中使用类似如下的配置实现模块:    

<configuration>
<system.web>
<identity impersonate="true" userName="accountname" password="password" />
</system.web>
</configuration>

    关于模拟的信息可考虑:http://support.microsoft.com/kb/306158/zh-cnhttp://msdn.microsoft.com/en-us/library/xh507fc5.ASPX

  2. 修改注册表: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20 把 S-1-5-20重命名为其它名称。

    该方法只适用于Win2003,如果修改win7的系统,会导致windows激活失效。

  参考:

  http://www.kevinrohrbaugh.com/blog/tag/openxml

  http://*.com/questions/6679193/openxml-isolatedstorage-network-service-and-windows-server-2008

  http://*.com/questions/3242102/a-cause-for-hresult-0x80131468-when-accessing-isolatedstoragebackingstore

上一篇:算法16 啊哈算法 广度优先搜索( Breadth First Search, BFS) 迷宫问题 JAVA


下一篇:H264格式具体说明