- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用功能区创建了一个 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
异常消息是:
Interception de System.IO.IsolatedStorage.IsolatedStorageException
Message=Unable to determine the identity of domain. Source=mscorlib
StackTrace:
at System.IO.IsolatedStorage.IsolatedStorage._GetAccountingInfo(Evidence
evidence, Type evidenceType, IsolatedStorageScope fAssmDomApp, Object&
oNormalized)
at System.IO.IsolatedStorage.IsolatedStorage.GetAccountingInfo(Evidence
evidence, Type evidenceType, IsolatedStorageScope fAssmDomApp, String&
typeName, String& instanceName)
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.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 value)
at System.Xml.XmlTextWriter.Indent(Boolean beforeEndElement)
at System.Xml.XmlTextWriter.AutoComplete(Token token)
at System.Xml.XmlTextWriter.WriteStartElement(String prefix, String localName, String ns)
at System.Xml.XmlDOMTextWriter.WriteStartElement(String prefix, String localName, String ns)
at System.Xml.XmlElement.WriteStartElement(XmlWriter w)
at System.Xml.XmlElement.WriteElementTo(XmlWriter writer, XmlElement e)
at System.Xml.XmlElement.WriteTo(XmlWriter w)
at System.Xml.XmlDocument.WriteContentTo(XmlWriter xw)
at System.Xml.XmlDocument.WriteTo(XmlWriter w)
at System.Xml.XmlDocument.Save(Stream outStream) InnerException:
当文档大小大于 1 MB 时,会出现此问题。经过多次查找,用隔离存储进行了“保存” Action ,解决办法是:
但是对于这个项目,我无法使用 ClickOnce
并且无法修改注册表。
因此我对源代码进行了更改,以创建一个新域。
Imports DocumentFormat.OpenXml.Packaging
Imports System.IO
<Serializable()> Public Class ToIsolatedPackageSave
Public Sub Save(ByRef mainPart As MainDocumentPart, ByRef xmlDocument As Xml.XmlDocument)
Dim stream As IO.Stream
stream = mainPart.GetStream(FileMode.Create, FileAccess.Write)
xmlDocument.Save(stream) -----> same exception
End Sub
End Class
和
Dim stream As Stream
Dim isolatedPackageSave As ToIsolatedPackageSave
Dim isolatedAppDomain As AppDomain
Try
Dim isolatedAppDomainSetup As AppDomainSetup = New AppDomainSetup()
isolatedAppDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory
Dim isolatedEvidence As Evidence = New Evidence(AppDomain.CurrentDomain.Evidence)
isolatedEvidence.AddAssembly(Reflection.Assembly.GetExecutingAssembly().FullName)
isolatedEvidence.AddHost(New Zone(Security.SecurityZone.MyComputer))
isolatedAppDomain = AppDomain.CreateDomain("TrustIsolatedDomain", isolatedEvidence, isolatedAppDomainSetup)
isolatedPackageSave = isolatedAppDomain.CreateInstanceAndUnwrap(GetType(ToIsolatedPackageSave).Assembly.FullName, GetType(ToIsolatedPackageSave).FullName)
'(IsolatedPackageSave)isolatedAppDomainSetup.CreateInstanceAndUnwrap(GetType(ToIsolatedPackageSave).Assembly.FullName, GetType(ToIsolatedPackageSave).FullName)
isolatedPackageSave.Save(mainPart, MainXMLDoc)
Catch ex As Exception
Finally
AppDomain.Unload(isolatedAppDomain)
End Try
但是这段代码并不能解决我的问题。
最佳答案
我按照 Tim Lewis 在这篇文章中的建议注入(inject)了所需的安全证据: http://rekiwi.blogspot.com/2008/12/unable-to-determine-identity-of-domain.html
public void VerifySecurityEvidenceForIsolatedStorage(Assembly assembly)
{
var isEvidenceFound = true;
var initialAppDomainEvidence = System.Threading.Thread.GetDomain().Evidence;
try
{
// this will fail when the current AppDomain Evidence is instantiated via COM or in PowerShell
using (var usfdAttempt1 = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForDomain())
{
}
}
catch (System.IO.IsolatedStorage.IsolatedStorageException e)
{
isEvidenceFound = false;
}
if (!isEvidenceFound)
{
initialAppDomainEvidence.AddHostEvidence(new Url(assembly.Location));
initialAppDomainEvidence.AddHostEvidence(new Zone(SecurityZone.MyComputer));
var currentAppDomain = Thread.GetDomain();
var securityIdentityField = currentAppDomain.GetType().GetField("_SecurityIdentity", BindingFlags.Instance | BindingFlags.NonPublic);
securityIdentityField.SetValue(currentAppDomain, initialAppDomainEvidence);
var latestAppDomainEvidence = System.Threading.Thread.GetDomain().Evidence; // setting a breakpoint here will let you inspect the current app domain evidence
}
}
然后在启动时调用以下代码:
VerifySecurityEvidenceForIsolatedStorage(this.GetType().Assembly);
关于vb.net - Ms Word Addin 中的isolatedStorageException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23996655/
我已经使用 MS Word 和一大堆表单字段创建了一个应用程序表单,并且我有一个 Access db,可以从这个 Word 文档中导入我需要的所有数据,这要归功于: http://msdn.micro
我试图找到一种将 Outlook 插件发布到办公商店的方法。但我发现我们只能发布 Office 应用程序,而不能发布 Office 商店的加载项。因此我想知道 Office 应用程序和 Office
我在 MS Reporting Services 服务器上部署了一份报告,工作正常。我可以使用 Microsoft 的报表查看器组件从 ASPX 页面毫无问题地 Access 它、设置报表参数等。效果
让我们再试一次。我发布这个是为了回答 2 个问题 MS Project 2007 是否需要 SharePoint(我希望没有)? 做 你喜欢 MS Project 开发团队 - 它是有用的还是 疼痛?
我正在执行这些星期六上午的任务之一,试图理解为什么为什么要在计算机注册表中搜索某些信息会花费大量时间,甚至迫使我停止该过程。使用这些注册表清理程序之一,我发现该代码花了数十分钟遍历如下行: HKEY_
从多年前开始,我就没有使用Access。 它能很好地解决什么样的问题,甚至比真正的RDBMS支持的Web应用程序更好? 它仍在积极开发吗?还是MS已经死了? 最大的局限性是什么? 更新: 应该使用什么
我们计划重新设计一个相当庞大的 MS Access 应用程序。有没有办法在同一应用程序上同时工作,或者是否可以合并同一文件的两个单独实例(不是数据,而是表单和代码)。现在 Access 包含数据,但在
我写了一些SQL命令来更正表中的字段。由于它是如此之小(也许我有点自大),我什至没有运行过一次,只是将其放入了更新包中供其他用户使用。 Dim SQL As String Dim rs As DAO.
它是Office自带的,是一个“中规中矩”的数据库,到今天这里有800多个问题,但我从来没有关注过它。 我失去了一些有趣的东西? 我说的是 MS-Access 作为用于快速原型(prototype)制
我有一个MS-Access数据库,该数据库已通过使用“用于Access的Microsoft SQL Server迁移助手2008”(aka SSMA)转换为使用SQL表并创建了链接表(因此,MS-Ac
我有一个 Excel 文件,其中包含从 Access 数据库(主数据库)导出的任务。然后,此 Excel 文件用作 MS Project 的导入文件。随后,MS Project 用于实际跟踪和报告,并
我正在尝试获取有关如何将 MS Project 2010 连接到 MS Project Server 2010 的教程或分步说明。 我已经在我的服务器上安装了 Server 2008 R2(64 位)
有没有办法像选择查询一样在查询中引用表单的组合框/文本框? 我通常在选择查询的条件中使用类似这样的东西: like forms!frmMain.qTitleofSomething&* (acces
我想创建一个表,其中包含 DOUBLE 实数类型的列。我可以在表设计 View 中找到数据类型 Number,但是没有 Double 或 single,Float.. 如何实现..? 我还需要 SQL
我环顾四周,发现了一些关于如何从字段的“描述”框中获取描述的 VBA 代码,但没有找到如何在表单属性中使用它的方法。 我希望出现一个 ControlTip,其中包含从数据库中的描述中带来的该字段的描述
我有一个难题。我已经开发了一个 Access 应用程序,我正准备分发它。我刚刚拆分了数据库。 (我知道,有人说我应该从一开始就把它分开开发……我没有)我也刚刚加密了后端数据库。在前端,我已链接到后端并
我制作了一个 MS Access 2013 数据库来跟踪有关交易网站的所有通信。与此问题相关的表和列是具有列 ID(编号)和链接(超链接)的广告,以及具有列广告的注释,其中包含广告 ID。链接字段包含
我与我不拥有且无法更改的数据库建立了 ODBC 连接。我要做的是使相关记录合并为一条记录。关系是一对多。 我有一个学生管理系统,想要导出一个提供自动标注服务(由调用收费)的调用列表。如果有多个学生住在
我在 Access 的表单中设置了一个文本框。该表单链接到一个表格。但是它自己的文本框是未绑定(bind)的,它用于简单地收集用户输入。但是,我无法编辑它所查看的值。 文本框未锁定。文本框可以在 VB
很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .
我是一名优秀的程序员,十分优秀!