Intermittent unable to create store directory, IsolatedStorage

Sep 17, 2010 at 11:54 AM

Hi

We have a problem with generating saving our xcel data. This only happens with some queries, but not with others. And it works perfectly in VS2010, but not when published.

this is the situation:

We have a webserverice that puts data into an exceltemplate and then saves it in a folder on the server, the access rights are correct since files can be save with the same data for another entity. The service is run under iis 6 and the project is compiled in dotnet 3.5.

Doesn anyone have any idea what we can do to get around this?

stacktrace:

00000076 13:24:05 [3168] Error in DoTemplateBasedReportSystem.IO.IsolatedStorage.IsolatedStorageException: Unable to create the store directory. (Exception from HRESULT: 0x80131468)  
00000077 13:24:05 [3168]    at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope, StringHandleOnStack retRootDir)  
00000078 13:24:05 [3168]    at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope)  
00000079 13:24:05 [3168]    at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope)  
00000080 13:24:05 [3168]    at System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope)  
00000081 13:24:05 [3168]    at System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope)  
00000082 13:24:05 [3168]    at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)  
00000083 13:24:05 [3168]    at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder.GetCurrentStore()  
00000084 13:24:05 [3168]    at MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder..ctor()  
00000085 13:24:05 [3168]    at MS.Internal.IO.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile()  
00000086 13:24:05 [3168]    at MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount, String& fileName)  
00000087 13:24:05 [3168]    at MS.Internal.IO.Packaging.SparseMemoryStream.SwitchModeIfNecessary()  
00000088 13:24:05 [3168]    at MS.Internal.IO.Packaging.SparseMemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)  
00000089 13:24:05 [3168]    at MS.Internal.IO.Packaging.CompressEmulationStream.Write(Byte[] buffer, Int32 offset, Int32 count)  
00000090 13:24:05 [3168]    at MS.Internal.IO.Packaging.CompressStream.Write(Byte[] buffer, Int32 offset, Int32 count)  
00000091 13:24:05 [3168]    at MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(Byte[] buffer, Int32 offset, Int32 count)  
00000092 13:24:05 [3168]    at MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(Byte[] buffer, Int32 offset, Int32 count)  
00000093 13:24:05 [3168]    at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)  
00000094 13:24:05 [3168]    at System.IO.StreamWriter.Write(String value)  
00000095 13:24:05 [3168]    at System.IO.TextWriter.Write(String format, Object arg0, Object arg1)  
00000096 13:24:05 [3168]    at OfficeOpenXml.ExcelWorksheet.UpdateRowCellData(StreamWriter sw, List`1& rowBreaks)  
00000097 13:24:05 [3168]    at OfficeOpenXml.ExcelWorksheet.SaveXml()  
00000098 13:24:05 [3168]    at OfficeOpenXml.ExcelWorksheet.Save()  
00000099 13:24:05 [3168]    at OfficeOpenXml.ExcelWorkbook.Save()  
00000100 13:24:05 [3168]    at OfficeOpenXml.ExcelPackage.Save()  

 

Coordinator
Sep 17, 2010 at 11:59 AM

Hi,

I think you have the same problem as in this thread...

http://epplus.codeplex.com/Thread/View.aspx?ThreadId=215730

Jan

Sep 17, 2010 at 1:19 PM
Edited Sep 17, 2010 at 1:48 PM

I don't think so. We can create files under 1mb but over that it can't.

I don't udnerstand why it uses IsolatedStorage, when we create the file. We create the folder serverside, and save the file there in an ouput folder, returning the link only to the browser. Problem is I find no refrences to IsolatedStorage anywhere, so why is it usning this?

Oh, and we can use the InccreaseQuotaTo because it is serverside...or that's what I think is the problem with changing quota.

/Erik

Coordinator
Sep 17, 2010 at 1:44 PM

The package-API uses Isolated Storage internally in some way.

Just to verify, did you add the folder and set the permission as described in the article?

http://labs.episerver.com/en/Blogs/Svante-Seleborg/Dates/2008/10/IsolatedStorage-Access-Denied/

Sep 17, 2010 at 1:52 PM
Edited Sep 17, 2010 at 1:53 PM

Yes we did make sure the article steps were made, though the difference is that this folder is defined under inetpub/wwwroot/STTReportHost/Output where we generate one folder per webuser. In essence everyuser that generates a file has his own folder named by his GUID from the database.

Is there any way to get around Isolatedstorage?

The users are not Domain users! So the IIS is the server user here.

/Erik

Coordinator
Sep 20, 2010 at 6:30 AM

I'm no expert when if comes to IIS, but I guess you have to make sure that the user running under the IIS user context has the appropriate permissions.

The isolated storage is used by the .net framework internal Zip classes,so it's out of my control.

/Jan

Sep 20, 2010 at 7:34 AM
Edited Sep 20, 2010 at 8:42 AM

Tried to use the stream, but ended up with a corrupted file.

/Erik  

 

 

Sep 20, 2010 at 8:43 AM

Question: Are we allowed to make the WorkBook.Save() public or an extra public method that calls it?

/Erik

Coordinator
Sep 20, 2010 at 9:06 AM

if you create the package with no parameters like ...

pck = new ExcelPackage();
or with a template...
pck = new ExcelPackage(new FileInfo("Tempalte.xlsx"),true);

Will be the same thing (the package will be closed after the save though). Try to use the SaveAs and GetAsByteArray and see if it helps you.
Sep 20, 2010 at 12:39 PM
Edited Sep 20, 2010 at 1:57 PM

Well, now it is solved.

Well, we can say that we misinterpreted the info in the link about the default user local settings/application data or appropriate folder folder and rights to mean that selected folder was actually the one used. Well, sorry for being a bit thick :)

/erik

 

Coordinator
Sep 21, 2010 at 6:31 AM

ok, great :)