none
Isolated storage issue when word creates a lot of content controls on the fly RRS feed

  • Question

  • Here's the stack trace I received when when I execute

    WordprocessingDocument.Close()
    

    We write/create huge number of content controls on the fly as a part of report generation process. Write/Creation of content controls does not create any issues, but dest.Close throws an error, which is something I am not able to comprehend. When I manually try to open the generated document, I get "document.xml is corrupt message.

     

    I was wondering, if there is any limits on the number of content controls that can be used in a word document? Can we increase the size of IsolatedStorage? alternatively, Can we get rid of IsolatedStorage, will there be any down-side to that?

    using
     (WordprocessingDocument
     dest = WordprocessingDocument
    .Open(outputfileName, true
    ))
                {
                    root.Write(context, dest);
                    if  (saveXml)
                    {
                        File .WriteAllText(generatorArguments.OutputFileName + ".xml" , dest.MainDocumentPart.Document.Body.OuterXml);
                    }
                    dest.Close();
                }

     

    --Inner Exception--
    System.IO.IsolatedStorage.IsolatedStorageException: Unable to determine domain of the caller.
       at System.IO.IsolatedStorage.IsolatedStorage._InitStore(IsolatedStorageScope scope, Evidence domainEv, Type domainEvidenceType, Evidence assemEv, Type assemblyEvidenceType, Evidence appEv, Type appEvidenceType)
       at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
       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.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
       at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
       at System.Xml.XmlWellFormedWriter.WriteString(String text)
       at DocumentFormat.OpenXml.OpenXmlElement.WriteAttributesTo(XmlWriter xmlWriter)
       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.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.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.SavePartContent(OpenXmlPart part)
       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.TrySavePartContent(OpenXmlPart part)
       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.SavePartContents()
       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose(Boolean disposing)
       at DocumentFormat.OpenXml.Packaging.OpenXmlPackage.Dispose()
       at Paisley.BoardReports.Generator.ReportGenerator.WriteReport(DocumentRoot root, GenerationContext context, String outputfileName, Boolean saveXml) in C:\projects\trunk\Net\BoardReports\Paisley.BoardReports.Generator\ReportGenerator.cs:line 263

    Wednesday, October 20, 2010 8:08 PM

All replies

  • I was able to find some more information on this.

    We generate Word Documents on the fly from MS-WordAddin and from command prompt.

    However big the document is, command prompt generation seem to work fine. But the Word Addin buckles pretty fast.

    My invoccation of the the following API's fail all the time when done through Addin - GetUserStoreForApplication, GetUserStoreForAssembly, GetUserStoreForDomain with the same error as above. I am guessing this is something to do with CAS for VSTO operations. Can someone shed some more light on this?

    Is there a way I can get the current execution context's (process/appdomain) IsolatedStorageFilePermissions information?

    Friday, October 22, 2010 1:15 PM
  • This problem has been simulated in much simpler format here......this issue has got nothing to do with the size od document. This is more to do with the behavior of VSTO and AppDomains.

    This problem can be completly avoided if the addin is installed using ClickOnce.

    If you are not using ClickOnce, may be someday I may find out a solution. Follow up on this issue can be found in this link

    http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/cda3b988-b371-42a9-8359-c6fc898a9a49

     

     

    Sunday, October 31, 2010 1:56 AM