小编Eur*_*oth的帖子

Word Addin中的IsolatedStorageException

我使用功能区创建了一个Word加载项项目,当我想保存文档时,在使用OpenXml进行多次修改后,会引发异常.

Dim MainXMLDoc As New XmlDocument()
Using WordDoc As WordprocessingDocument = WordprocessingDocument.Open(DocPath, True)

Dim mainPart As MainDocumentPart = WordDoc.MainDocumentPart
If Not mainPart Is Nothing Then

    MainXMLDoc.Load(mainPart.GetStream())
    EXmlDocument.XMLDoc = Nothing
    EXmlDocument.XMLDoc = MainXMLDoc
    EXmlDocument.GetWordDocIds()
    '..............
end if

'........
Dim stream As IO.Stream
stream = mainPart.GetStream(FileMode.Create, FileAccess.Write)

    MainXMLDoc.Save(stream) '-----> exception
Run Code Online (Sandbox Code Playgroud)

并且异常消息是:

Interception de System.IO.IsolatedStorage.IsolatedStorageException
Message =无法确定域的标识.Source = mscorlib StackTrace:System.IO.IsolatedStorage.IsolatedStorage._GetAccountingInfo(证据证据,Type evidenceType,IsolatedStorageScope fAssmDomApp,Object&oNormalized)在System.IO.IsolatedStorage.IsolatedStorage.GetAccountingInfo(证据证据,Type evidenceType,IsolatedStorageScope fAssmDomApp,String&typeName) ,字符串&实例名)在System.IO.IsolatedStorage.IsolatedStorage._InitStore(IsolatedStorageScope范围,循证domainEv,类型domainEvidenceType,证据assemEv,类型assemblyEvidenceType,证据appEv,类型appEvidenceType)在System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope范围,在MS.Internal.IO.Packaging的MS.Internal.IO.Packaging.PackagingUtilities.ReliableIsolatedStorageFileFolder.GetCurrentStore()上的System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope范围,类型domainEvidenceType,类型assemblyEvidenceType)中键入domainEvidenceType,Type assemblyEvidenceType) .PackagingUtilities.ReliableIs olatedStorageFileFolder..ctor()位于MS.Internal.IO.Package.Packaging.PackagingUtilities.GetDefaultIsolatedStorageFile(),位于MS.Internal.IO.Packaging.SparseMemoryStream的MS.Internal.IO.Packaging.PackagingUtilities.CreateUserScopedIsolatedStorageFileStreamWithRandomName(Int32 retryCount,String&fileName). SwitchModeIfNecessary()在MS.Internal.IO.Packaging.SparseMemoryStream.Write(字节[]缓冲液,的Int32偏移的Int32计数)在MS.Internal.IO.Packaging.CompressEmulationStream.Write(字节[]缓冲液,的Int32偏移的Int32计数)在MS.Internal.IO.Packaging.CompressStream.Write(字节[]缓冲液,的Int32偏移的Int32计数)在MS.Internal.IO.Zip.ProgressiveCrcCalculatingStream.Write(字节[]缓冲液,的Int32偏移的Int32计数)在MS.Internal.IO.Zip.ZipIOModeEnforcingStream.Write(字节[]缓冲液,的Int32偏移的Int32计数)在System.IO.StreamWriter.Flush(布尔flushStream,布尔flushEncoder)在System.IO.StreamWriter.Write(char值) System.Xml.Xm上的System.Xml.XmlTextWriter.Indent(Boolean beforeEndElement)lTextWriter.AutoComplete(令牌标记)在System.Xml.XmlTextWriter.WriteStartElement(字符串前缀,字符串的localName,串NS)在System.Xml.XmlDOMTextWriter.WriteStartElement(字符串前缀,字符串的localName,串NS)在System.Xml.XmlElement. WriteStartElement(XmlWriter的重量)在System.Xml.XmlElement.WriteElementTo(XmlWriter的作家,XmlElement的E)在System.Xml.XmlElement.WriteTo(XmlWriter的重量)在System.Xml.XmlDocument.WriteContentTo(XmlWriter的XW)在System.Xml.XmlDocument System.Xml.XmlDocument.Save(Stream outStream)中的.WriteTo(XmlWriter w)InnerException:

文档大小大于1 MB时出现此问题.经过多次搜索后,"保存"操作是通过隔离存储进行的,解决方案是:

  • 使用Clickonce安装
  • 创建新域
  • 修改注册表.

但对于这个项目,我不能使用ClickOnce,我无法修改注册表.

所以我对源代码进行了更改,以创建一个新域. …

vb.net vsto isolatedstorage openxml

5
推荐指数
2
解决办法
834
查看次数

标签 统计

isolatedstorage ×1

openxml ×1

vb.net ×1

vsto ×1