2011-10-10 174 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