2011-10-10 225 views
8

我在我的ASP.NET MVC 3應用程序中使用EPPlus 2.8.0.2庫來生成excel文件。此應用程序在Windows Server 2003 R2上的IIS 6上運行。IsolatedStorage初始化失敗

有問題的行是這樣的:

xlsdoc.GetAsByteArray 

xlsdoc是一個正確裝入ExcelPackage對象。

生成較小的輸出是好的,但產生大的輸出端產生一個錯誤:

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 

我懷疑EPPlus試圖創建使用IsolatedStorage臨時文件,但沒有寫權限IsolatedStorage。我已將應用程序池標識更改爲「本地系統」,並且錯誤消失。

如何在使用'網絡服務'身份時避免此錯誤?

+0

相關問題和其他人發現此問題的更多信息: http://epplus.codeplex.com/workitem/14762 – richardtallent

回答

8

某人blogged about this。他得到了(拒絕訪問)錯誤是從我得到的錯誤不同,但他的解決方案爲我工作:

  • C:\Documents and Settings\Default User\Local Settings\Application Data\IsolatedStorage
  • 給寫訪問給大家該文件夾
  • 在服務器上創建一個文件夾
+1

鏈接已關閉於2014-08-05 – JerryOL

0

這裏討論:http://openxmldeveloper.org/

提取物:

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