IsolatedStorageException: Unable to create the store directory

pedrofernandes picture pedrofernandes · Jun 24, 2009 · Viewed 9.9k times · Source

Hi I have to store some hidden information in Isolated space. For that I am using System.IO.Isolated class like

IsolatedStorageFile isf =     System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
Stream writer = new IsolatedStorageFileStream(filename, FileMode.Create, isf);

IFormatter formatter = new BinaryFormatter();
formatter.Serialize(writer, appCollection.ToString());

writer.Close();

It works fine in Windows XP but on production server that is windows 2003 it shows exception

System.IO.IsolatedStorage.IsolatedStorageException: Unable to create the store directory.

I have a Everyone full control permissions in my asp.net project folder. Attention CSoft.Core is a personal Framework created by me.

This is my Stack Trace:

[IsolatedStorageException: Unable to create the store directory. (Exception from HRESULT: 0x80131468)]
System.IO.IsolatedStorage.IsolatedStorageFile.nGetRootDir(IsolatedStorageScope scope) +0
System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope) +97
System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope) +137
System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope) +213
System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope) +56
System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType) +59
CSoft.Core.IO.StorageHelper.Save(String fileName, String content) in c:\Projectos\FrameworkCS\CSoft.Core\IO\StorageHelper.cs:18
CSoft.Web.UI.ViewStateHelper.SerializeViewState(HttpContext context, Object state) in c:\Projectos\FrameworkCS\CSoft.Web.Controls\Web\UI\ViewStateHelper.cs:65 CSoft.Web.UI.Page.SavePageStateToPersistenceMedium(Object state) in c:\Projectos\FrameworkCS\CSoft.Web.Controls\Web\UI\Page.cs:302
System.Web.UI.Page.SaveAllState() +236
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1099

Answer

Przemek Ptasznik picture Przemek Ptasznik · Sep 13, 2013

If it's running on IIS and application pool identity is NetworkService, You can try to go to advanced settings of application pool and set "Load user profile" value to "True". Worked for me.