DocX文件保存时初始化失败

时间:2013-01-11 19:31:16

标签: c#-4.0 ms-word iis-6 openxml docx

我遇到以下错误:

Message: Initialization failed.
Source: mscorlib
Stack Trace: 
   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(Char[] buffer, Int32 index, Int32 count)
   at System.Xml.XmlEncodedRawTextWriter.FlushBuffer()
   at System.Xml.XmlEncodedRawTextWriter.RawText(Char* pSrcBegin, Char* pSrcEnd)
   at System.Xml.XmlEncodedRawTextWriter.RawText(String s)
   at System.Xml.XmlEncodedRawTextWriter.WriteStartAttribute(String prefix, String localName, String ns)
   at System.Xml.XmlEncodedRawTextWriterIndent.WriteStartAttribute(String prefix, String localName, String ns)
   at System.Xml.XmlWellFormedWriter.WriteStartAttribute(String prefix, String localName, String namespaceName)
   at System.Xml.Linq.ElementWriter.WriteStartElement(XElement e)
   at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
   at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
   at System.Xml.Linq.XContainer.WriteContentTo(XmlWriter writer)
   at System.Xml.Linq.XDocument.WriteTo(XmlWriter writer)
   at System.Xml.Linq.XDocument.Save(TextWriter textWriter, SaveOptions options)
   at System.Xml.Linq.XDocument.Save(TextWriter textWriter)
   at Novacode.DocX.InsertDocument(DocX document)
   at SpringWireless.Common.Server.Ws.IntegrationStudio.ProjectDocumentation.Factory.GenerateNewFile()

我只是试图将文档插入另一个,多次(+ - 300个文档),循环播放。

有人知道为什么会这样吗?

此错误仅发生在服务器上,在我的机器上,运行正常。

1 个答案:

答案 0 :(得分:1)

Docx Api使用IsolatedStorage编写一些大文件。 因此,IIS需要具有在IsolatedStorage文件夹中读写的权限。

因此,只需添加池用户或“Everyone”的权限,即可在该文件夹中进行读写操作: “C:\ Documents and Settings \ Default User \ Local Settings \ Application Data \ IsolatedStorage”