Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.60/5 (4 votes)
Hello,

I have written code to generate xlsx file using OpenXML. It's working very well on my local machine through IIS and through visual studio. I have hosted the web application on windows server 2003 and on windows server 2008. The excel file are generating fine for small data. But when the data is large i.e. more than 300 rows and 20 columns then I'm getting the exception "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))".

I checked for this issue on Google and found solution for windows server 2003 where they have mentioned to 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 and now my web application generating the excel files with large amount of data.

For windows server 2008 someone has mentioned to made change in the following registry:

Rename the registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20 to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-20-backup

This didn't solve the problem but creates another problem for me, now after rebooting the server I'm not able to log in to my server.

I'm stuck in this problem from last 5 days, please help me regarding solving the problem "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" on windows server 2008.

For reference please check the attached screenshot showing the error and some part of the code.

Thanks,
Kunal Khosla
Posted
Comments
Tejas Vaishnav 13-Mar-14 9:55am    
You are trying to access restricted registry, means your user (windows) is not having rights to modify that registry key or value.
Maciej Los 13-Mar-14 16:55pm    
Do you have another account with admin privileges? If yes, use it to log in to Server 2008 and restore registry entry.
Kunal Khosla 14-Mar-14 0:08am    
Thanks for the reply Tejas and Maciej.

I have already fixed the problem regarding login into server 2008. I need some help/solution regarding main issue that I'm getting "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

As I mentioned in the post I checked for this issue on Google and found solution for windows server 2003 and according to which I created IsolatedStorage folder 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 issue for windows server 2003, now excel file with large data gets created without any issue.

So now I'm looking for solution on windows server 2008.
AdamASPGeek 14-Mar-14 1:10am    
Hi Kunal,

From the error message it seems about the permission issue. Have you try to give full permission to your folder?
Kunal Khosla 14-Mar-14 1:44am    
Hello Adam,

Yes I have given full permission to that folder for the following:

Everyone
Administrators
IIS_WPG
Network Service

Below is the detailed exception:

Error: Exception: System.ApplicationException
Message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Source: mscorlib
at System.IO.IsolatedStorage.IsolatedStorageFile.nGetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.InitGlobalsNonRoamingUser(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetRootDir(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetGlobalFileIOPerm(IsolatedStorageScope scope)
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.EnsureIsolatedStoreStream()
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.Xml.XmlUtf8RawTextWriter.FlushBuffer()
at System.Xml.XmlUtf8RawTextWriter.RawText(Char* pSrcBegin, Char* pSrcEnd)
at System.Xml.XmlUtf8RawTextWriter.RawText(String s)
at System.Xml.XmlUtf8RawTextWriter.WriteEndElement(String prefix, String localName, String ns)
at System.Xml.XmlWellFormedWriter.ElementScope.WriteEndElement(XmlRawWriter rawWriter)
at System.Xml.XmlWellFormedWriter.WriteEndElement()
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlCompositeElement.WriteContentTo(XmlWriter w)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.SaveToPart(OpenXmlPart openXmlPart)
at DocumentFormat.OpenXml.OpenXmlPartRootElement.Save()
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.SavePartContents()
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose(Boolean disposing)
at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose()
at TestProj.ExportToExcelNew.CreateExcel2(String path, String entityType, String userIteration, Int64 ProjectId, Int64 CurrentUserId, List`1 lstSortOption, List`1 data, String& fileName)

Hi Kunal,

Check for the excel file (it is read only or not). If you have given all the permission to respective files and folder, then share your code if you can.

Ajit
 
Share this answer
 
Comments
Kunal Khosla 14-Mar-14 2:27am    
Hello Ajit,

The excel file is creating while running the code. The folder has full permission for following :
Everyone
Administrators
IIS_WPG
Network Service

For small data around 300 rows it's works very well and successfully creates a new excel file with the data.
What are you using for dumping the data into excel sheet.. i mean OLE DB or something different..

check for the closing and opening of object.. or better to use Using keyword...

If you can share you code it would be good to response ....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900