Initialization failed on IsolatedStorage
Asked Answered
L

2

9

I am using EPPlus 2.8.0.2 library in my ASP.NET MVC 3 app to generate excel files. This application runs on IIS 6 on Windows Server 2003 R2.

The offending line is this:

xlsdoc.GetAsByteArray

xlsdoc is a properly loaded ExcelPackage object.

Generating small output is fine, but generating big output produces an error:

System.IO.IsolatedStorage.IsolatedStorageException: Initialization failed.
   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.GetCurrentStore()
   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.SwitchModeIfNecessary()
   at MS.Internal.IO.Packaging.SparseMemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MS.Internal.IO.Packaging.CompressEmulationStream.Write(Byte[] buffer, 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.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Write(String value)
   at System.IO.TextWriter.Write(String format, Object arg0)
   at OfficeOpenXml.ExcelWorksheet.UpdateRowCellData(StreamWriter sw)
   at OfficeOpenXml.ExcelWorksheet.SaveXml()
   at OfficeOpenXml.ExcelWorksheet.Save()
   at OfficeOpenXml.ExcelWorkbook.Save()
   at OfficeOpenXml.ExcelPackage.GetAsByteArray(Boolean save)
   at OfficeOpenXml.ExcelPackage.GetAsByteArray()
   at ReportCenterLib.ReportGenerator.GenerateStream(DataTable result, String reporttitle, String inputparmstr, String conndescs, String username, String outputtype, String templatefile) in D:\PROJECTS\reportcentermvc\sources\ReportCenterLib\ReportGenerator.vb:line 450
   at ReportCenterMVC.ReportCenterMVC.ReportController.Generate(Int64 id, IList`1 conns, IDictionary`2 parms, String outputtype) in D:\PROJECTS\reportcentermvc\sources\ReportCenterMVC\Controllers\ReportController.vb:line 218

I suspect EPPlus tries to create temporary files using IsolatedStorage, but didn't have permission to write to IsolatedStorage. I have changed the application pool identity to 'local system', and the error disappears.

How do I avoid this error while using 'network service' identity?

Luciana answered 10/10, 2011 at 10:15 Comment(1)
Related issue and more information for anyone else finding this: epplus.codeplex.com/workitem/14762Bunni
L
8

Someone blogged about this. The error he got (access denied) was different from the error that I got, but his solution worked for me:

  • Create a folder on the server at C:\Documents and Settings\Default User\Local Settings\Application Data\IsolatedStorage
  • Give write access to everyone to that folder
Luciana answered 11/10, 2011 at 2:56 Comment(1)
link dead on 2014-08-05Lees
L
0

Discussed here: http://openxmldeveloper.org/

extract:

create folder named IsolatedStorage at the following path "C:\Documents and Settings\Default User\Local Settings\Application Data" and give the permission for IIS_WPG to modify and write. This solves the problem on the windows server 2003

Lees answered 5/8, 2014 at 21:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.