Ms word VSTO 4服务器文档类失败
我有一个单词VSTO addin,它将文档保存到安全的网络共享中。保存过程通过模拟具有安全共享访问权限的Active Directory帐户来完成。它的一部分是将文档复制到网络共享,并删除定制(其他部分包括更新数据库-与手头的问题无关) ServerDocument类方法存在异常(即使只是尝试。RemoveCustomization对具有自定义功能的文档不起作用) 引发的异常包括:Ms word VSTO 4服务器文档类失败,ms-word,ms-office,vsto,office-addins,Ms Word,Ms Office,Vsto,Office Addins,我有一个单词VSTO addin,它将文档保存到安全的网络共享中。保存过程通过模拟具有安全共享访问权限的Active Directory帐户来完成。它的一部分是将文档复制到网络共享,并删除定制(其他部分包括更新数据库-与手头的问题无关) ServerDocument类方法存在异常(即使只是尝试。RemoveCustomization对具有自定义功能的文档不起作用) 引发的异常包括: The type initializer for 'MS.Utility.EventTrace' threw an
The type initializer for 'MS.Utility.EventTrace' threw an exception.. Source: WindowsBase. StackTrace:
at MS.Utility.EventTrace.EasyTraceEvent(Keyword keywords, Event eventID)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess)
at Microsoft.Office.Tools.OfficeOpenXmlAppInfoDocument.Microsoft.VisualStudio.Tools.Applications.Runtime.IAppInfoDocument.SetDocument(String fileName, Byte[] data, FileAccess fileAccess)
at Microsoft.VisualStudio.Tools.Applications.AppInfoDocumentFactory.GetAppInfoDocument(String documentPath, Byte[] bytes, FileAccess access)
at Microsoft.VisualStudio.Tools.Applications.ServerDocument.Initialize(Byte[] bytes, String documentPathOrFileType, FileAccess access, Boolean throwOnPreviousVersion)
at Microsoft.VisualStudio.Tools.Applications.ServerDocument.Initialize(Byte[] bytes, String documentPathOrFileType, FileAccess access)
at Microsoft.VisualStudio.Tools.Applications.ServerDocument..ctor(String documentPath, FileAccess access)
at Microsoft.VisualStudio.Tools.Applications.ServerDocument.IsCustomized(String documentPath)
at DMS.ActiveDocument.SaveActiveDocument(). InnerException Message: Requested registry access is not allowed.. InnerException Source: mscorlib
另一个例外是:
Failed to save remotely (ID=123).
The type initializer for 'MS.Utility.EventTrace' threw an exception..
Source: ADDINNAME. StackTrace: at ADDINNAME.CLASSNAME.METHODNAME()
这些事情接二连三地发生
这发生在Windows 10 Office 2016或Windows 7 Office 2007上。加载项本身最初是使用VS 2008 VSTO 3 for Windows 7 Office 2007环境开发的,并已使用VS 2017迁移到使用VSTO 4(自动过程)
抛出错误时,“Warmpup”注册表项似乎正常(外接程序一直在正确加载)。我们调查了这是否与DNS问题有关,但这似乎发生在IP中存在或不存在任何冲突的PC上。我们还尝试在受影响的PC上重新安装VSTO 4,但没有成功
这个问题似乎突然发生,几天后可能会消失
感谢您的帮助。还要注意的是,我们有一个小用户,每天使用该应用程序的用户约为1000人——这只会偶尔发生在少数用户身上。Visual Studio 2010 Office运行时工具中有两个不同版本的
ServerDocument
类。应使用的版本取决于要在其中使用类的应用程序的目标.NET Framework:
- 对于以.NET Framework 4或.NET Framework 4.5为目标的应用程序,请使用
程序集中的Microsoft.VisualStudio.Tools.applications.ServerDocument
类李>Microsoft.VisualStudio.Tools.applications.ServerDocument.dll
- 对于以.NET Framework 3.5为目标的应用程序,请使用
程序集中的Microsoft.VisualStudio.Tools.applications.ServerDocument
类李>Microsoft.VisualStudio.Tools.applications.ServerDocument.v10.0.dll
有关更多信息,请参阅。我们认为我们已经找到了解决此问题的方法。一些人建议使用此代码来解决类似的问题(请阅读到最后):
这似乎对我们有用。谢谢您的回复。我们的目标是.NET Framework 4.5,并使用Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll。我们还尝试在受影响的PC上添加模拟帐户作为管理员(遵循“不允许请求注册表访问”),但没有帮助。。。
Failed to save remotely (ID=123).
The type initializer for 'MS.Utility.EventTrace' threw an exception..
Source: ADDINNAME. StackTrace: at ADDINNAME.CLASSNAME.METHODNAME()