Word 2010 插件无法加载,vsto 2010

发布于 2024-09-26 11:46:29 字数 7780 浏览 5 评论 0原文

我们的开发机器是 64 位硬件,运行 Windows 7 Professional N(64 位)、64 位 Office Professional 2010 和 Visual Studio Professional 2010。

我们使用 .NET Framework 4、功能区和 Windows 安装程序创建了 Word 2010(应用程序级加载项)针对 Office 2010。我们多次遵循从官方 MSDN 在线教程到 dot 的所有内容。对于我们的安装程序,我们选择 .NET 4 客户端配置文件和 Windows 安装程序 3.1 作为先决条件,因为 Office 2010 安装了 VSTO 4.0 运行时,并且 .NET Framework 4 没有 PIA 功能。在启动条件下,我们使用适当的组件 ID 检查 Office 2010 共享 PIA 和 Word 2010 PIA 的可用性。此外,我们还检查了 VSTO 运行时可用性,如 MSDN 文章中所述。

我们的外接程序仅在 Visual Studio 调试 (F5) 中加载并执行完整功能。构建安装项目会创建 Windows 安装程序 (msi)。安装它会在计算机上安装加载项,不会出现任何错误。但是,安装加载项后,当我们尝试打开任何 Word 2010 文档时,我们会看到以下行为:

  1. 我们尝试打开任何 Microsoft Word 2010 文档,出现 Word 2010 启动屏幕,我们可以看到我们的加载项 -正在加载“正在加载[我们的]加载项”,但 Word 2010 无法打开。启动屏幕消失并且不显示错误消息。

  2. 第二次打开 Word 文档只会弹出此消息(这次没有 Word 2010 启动屏幕):

    <块引用>

    Word 在使用“[我们的]单词插件” 加载项时遇到了严重问题。如果您多次看到此消息,则应禁用此加载项并检查是否有可用更新。您想禁用此加载项吗?

    单击“否”,会短暂启动 Microsoft Word 2010 的启动屏幕,然后再次停止加载(消失)。单击“是”将打开 Word 2010,并禁用 [我们的] 添加项。通过单击“文件”-“选项”-“插件”进行验证。查看“禁用的应用程序加载项”

    设置 VSTO_SUPPRESSDISPLAYALERTS=0VSTO_LOGALERTS=1 也没有用。我们检查了 Temp 目录,没有日志。

  3. 由于上述方法不起作用,我从名为 “使用 Windows Installer 为 Office 2007/2010 部署 VSTO 2010 解决方案”,并使用在 Office 开发下找到的相应项目 - 安装和部署项目示例\FX40\AddIn Deployment\All User Install for 64-位Office

    最初,我通过创建并运行安装程序 (msi) 测试了正确加载演示 Excel 2010 加载项项目的解决方案,然后我们将 Word 加载项项目按文件添加到解决方案文件中并正确构建它 (CTRL +SHIFT+B)。它甚至可以从 Visual Studio 调试 (F5) 正确运行。然后,我们重新配置现有的设置项目以删除演示 Excel 项目并加载 Word 插件的主要输出、[OurAdd-In].vsto 和 [OurAdd-In].dll.manifest 文件。我们刷新了项目依赖项并采取了适当的步骤来排除相关文件。我们保持了注册表检查的完整性,并添加了启动条件来检查 Word 2010 PIA。

    安装程序已成功构建并安装,没有错误,但不幸的是,我们目睹了与前面描述的 Word 2010 完全相同的行为。

我们还尝试使用 Windows 事件日志记录进行调试。我发现此事件的事件 ID 为 4096:

************** Exception Text **************
Microsoft.VisualStudio.Tools.Applications.Deployment.FrameworkVersionMismatchException: <compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
 <framework targetVersion="4.0" profile="Client" supportedRuntime="4.0.30319" />
 <framework targetVersion="4.0" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>

我们需要为 32 位和 64 位 Word 2010 的 Word 加载项创建一个安装程序。


我进行了进一步研究,这就是我发现的内容。

我使用 AddInSpy 进行了进一步调查,这是我得到的调试信息...

<addIn>
 <Item>1</Item> 
 <Host>Word</Host> 
 <Running>true</Running> 
 <Loaded>false</Loaded> 
 <Type>VSTO</Type> 
 <FriendlyName>[OURADDIN]WordAddIn</FriendlyName> 
 <ProgID>[OURADDIN].WordAddIn</ProgID> 
 <CLSID>n/a</CLSID> 
 <Manifest>C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN]WordAddIn.vsto|vstolocal</Manifest> 
 <DllPath>C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN]WordAddIn.dll</DllPath> 
 <LoadBehavior>3</LoadBehavior> 
 <RegHive>HKCU</RegHive> 
 <AssemblyName>?</AssemblyName> 
 <CLR_version>?</CLR_version> 
 <Exposed>false</Exposed> 
 <Interfaces>?</Interfaces> 
 <FormRegions>n/a</FormRegions> 
 <VSTOR>2008</VSTOR> 
 <Installed>?</Installed> 
 <PubVer>n/a</PubVer> 
 <Status>Alert</Status> 
 <StatusDescription>Add-in DLL path is not found. System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN].dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN].dll'
  at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
  at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
  at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
  at AddInSpy.AssemblyScanner.GetAssemblyInfo(String fileName, String hostName, Boolean isVstoAddIn)

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Users\Interance\Downloads\AddInSpy\AddInSpy.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = Interance-PC\Interance
LOG: Where-ref bind. Location = C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN].dll
LOG: Appbase = file:///C:/Users/Interance/Downloads/AddInSpy/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft/[OURADDIN]Setup2010/[OURADDIN]AddIn.dll.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.
</StatusDescription> 
 </addIn>

我相信上面有趣的是以下几行

该程序集是由比当前加载的运行时更新的运行时构建的 运行时且无法加载...

程序集管理器加载自: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll

日志:使用来自 C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config。

据我了解,Word 2010 正在尝试使用引用固件版本 v2.0.50727 的程序集管理器和计算机配置文件加载我的加载项,而它应该引用 \Framework64\v4.0.30319\ 因为我使用 .NET 4 构建了我的外接程序。因此出现错误消息 “此程序集是由比当前加载的运行时更新的运行时构建的,无法加载...”

我认为这可能是来源。有什么想法可能会发生这种情况以及如何解决它?


嗯...我想我应该早点提到这一点,但我正在使用 open xml 2 sdk 使用 .NET f/w 4 在我的 Word 2010 加载项中创建/读取 Word 文件。我遵循了 此处提供的文档。如果向下滚动该页面,您将在介绍 Open XML SDK 格式架构部分中找到系统支持层,它支持 .NET f/w 3.5,并且当前 Open XML 格式 SDK 基于标准 Ecma -376。

此外,经过几个小时的眯着眼睛阅读大量文章,例如 Chris Rae 的 详细文章< /a> 其中他指出 Office 2010 使用另一个标准 ISO/IEC 29500 作为其默认文件格式,而 Office 2007 支持 ECMA-376。它还进一步指出:

ISO/IEC 29500 是 ECMA-376 的直接后代。事实上,它是直接的后代,以至于 ECMA-376 第二版与 ISO/IEC 29500 相同。

我发现 Open XML SDK Format Architecture 系统支持层支持 .NET f/w 3.5,目前 Open XML Format SDK 2 基于标准 Ecma-376。

参考链接

因此我'我只是想知道 Open XML SDK 2 是否是我的问题的根源?由于 ISO/IEC 29500 是 ECMA-376 的后代,我可以使用 Open XML SDK 2 在代码中创建/修改 word 2010 文档吗?

这就是程序集管理器和机器配置文件从 framework\v2.0.50727\ 而不是从 \Framework64\v4.0.30319\ 加载的原因吗?

Our development machine is 64 bit hardware running Windows 7 Professional N (64 bit), 64 bit Office Professional 2010 and Visual Studio Professional 2010.

We created a Word 2010 (Application Level Add-In) using .NET Framework 4, Ribbons and Windows installer targeting Office 2010. We followed everything from the official MSDN online tutorials to the dot several times. For our installer we selected .NET 4 client profile and Windows installer 3.1 as prerequisites, since Office 2010 has VSTO 4.0 runtime installed and .NET framework 4 has no-PIA functionality. In launch conditions we checked for Office 2010 Shared PIA and Word 2010 PIA availability using the appropriate component ids. Additionally we checked for VSTO runtime availability as is laid out in the MSDN article.

Our Add-In loads and executes with full functionality from ONLY within Visual Studio debug (F5). Building the setup project creates the Windows installer (msi). Installing it installs the Add-In on the machine without any errors. However after installing the Add-In when we try to open any Word 2010 document, we are witnessing the following behavior:

  1. We try to open any Microsoft Word 2010 document, Word 2010 startup screen shows up and we can see our Add-In being loaded "Loading [Our] Add-In" but then Word 2010 does not open. The startup screen disappears and no error message is displayed.

  2. Opening the word document for the second time just fires up this message (no word 2010 startup screen this time):

    Word experienced a serious problem with the '[Our] word addin' add-in. If you have seen this message multiple times, you should disable this add-in and check to see if an update is available. Do you want to disable this add-in?'

    Clicking on No, briefly fires up the startup screen of Microsoft Word 2010 and then it stops loading again (disappears). Clicking on Yes, opens Word 2010 with the [Our] add in disabled. Verified by clicking File-Options-AddIns. Looked under Disabled Application Add-Ins

    Setting VSTO_SUPPRESSDISPLAYALERTS=0 and VSTO_LOGALERTS=1 was of no use either. We checked our Temp directory, there were no logs.

  3. Since the above method did not work I downloaded the sample project from this link named 'Deploying a VSTO 2010 solution for Office 2007/2010 using Windows Installer' and used the appropriate project found under Office Development - Setup and Deployment Projects Samples\FX40\AddIn Deployment\All User Install for 64-bit Office.

    Initially I tested the solution to correctly load the demo Excel 2010 Add-In project by creating and running the installer (msi) Then we added our Word AddIn project to the solution file by file and built it correctly (CTRL+SHIFT+B). It even ran from Visual Studio debug (F5) correctly. Then we reconfigured the existing set up project to delete the demo Excel project and load our word Add-In's primary output, [OurAdd-In].vsto and [OurAdd-In].dll.manifest files. We refreshed project dependencies and took appropriate steps to exclude relevant files. We kept the registry checks intact and added launch conditions to check for Word 2010 PIA.

    The installer built successfully and installed without errors but unfortunately we witnessed the exact same behavior of Word 2010 as described previously.

We also tried debugging using Windows event logging. I found this event with event id 4096:

************** Exception Text **************
Microsoft.VisualStudio.Tools.Applications.Deployment.FrameworkVersionMismatchException: <compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
 <framework targetVersion="4.0" profile="Client" supportedRuntime="4.0.30319" />
 <framework targetVersion="4.0" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>

We need to create an installer for our Word Add-In for both 32-bit and 64-bit Word 2010.


I've researched further and this is what I've found.

I used AddInSpy to investigate further and this is the debug information I get ...

<addIn>
 <Item>1</Item> 
 <Host>Word</Host> 
 <Running>true</Running> 
 <Loaded>false</Loaded> 
 <Type>VSTO</Type> 
 <FriendlyName>[OURADDIN]WordAddIn</FriendlyName> 
 <ProgID>[OURADDIN].WordAddIn</ProgID> 
 <CLSID>n/a</CLSID> 
 <Manifest>C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN]WordAddIn.vsto|vstolocal</Manifest> 
 <DllPath>C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN]WordAddIn.dll</DllPath> 
 <LoadBehavior>3</LoadBehavior> 
 <RegHive>HKCU</RegHive> 
 <AssemblyName>?</AssemblyName> 
 <CLR_version>?</CLR_version> 
 <Exposed>false</Exposed> 
 <Interfaces>?</Interfaces> 
 <FormRegions>n/a</FormRegions> 
 <VSTOR>2008</VSTOR> 
 <Installed>?</Installed> 
 <PubVer>n/a</PubVer> 
 <Status>Alert</Status> 
 <StatusDescription>Add-in DLL path is not found. System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN].dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN].dll'
  at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
  at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
  at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
  at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)
  at AddInSpy.AssemblyScanner.GetAssemblyInfo(String fileName, String hostName, Boolean isVstoAddIn)

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable C:\Users\Interance\Downloads\AddInSpy\AddInSpy.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = Interance-PC\Interance
LOG: Where-ref bind. Location = C:\Program Files\Microsoft\[OURADDIN]Setup2010\[OURADDIN].dll
LOG: Appbase = file:///C:/Users/Interance/Downloads/AddInSpy/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This is an inspection only bind.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft/[OURADDIN]Setup2010/[OURADDIN]AddIn.dll.
ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.
</StatusDescription> 
 </addIn>

I believe what is interesting above are the following lines

This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded...

Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll

LOG: Using machine configuration file from
C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.

In my understanding Word 2010 is trying to load my Add-In using Assembly Manager and Machine Configuration File referencing F/W version v2.0.50727 when it should be referencing \Framework64\v4.0.30319\ since I've built my Add-In using .NET 4. As a consequence is the error message 'This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded...'

I think this might be the source. Any thoughts why this might be happening and how to resolve it?


Hmm... I think I should have mentioned this earlier but I'm using open xml 2 sdk to create/read word files in my Word 2010 Add-In with .NET f/w 4. I've followed the documentation provided here. If you scroll down that page you will find in the section Introducing Open XML SDK Format Architecture subsection system support layer that it supports .NET f/w 3.5 and currently the Open XML Format SDK is based on Standard Ecma-376.

Furthermore, after couple of hours of squinting and reading lots of articles such as Chris Rae's detailed article where he states that Office 2010 uses another standard, ISO/IEC 29500, as its default file format while Office 2007 supports ECMA-376. Further it states that:

ISO/IEC 29500 is a direct descendant of ECMA-376. It's so direct a descendant, in fact, that ECMA-376 2nd edition is identical to ISO/IEC 29500.

I found that Open XML SDK Format Architecture system support layer supports .NET f/w 3.5 and currently the Open XML Format SDK 2 is based on Standard Ecma-376.

Link for Reference

Therefore I'm just wondering if Open XML SDK 2 is the source of my problem? Since ISO/IEC 29500 is descendant of ECMA-376, can I use Open XML SDK 2 to create/modify word 2010 documents in my code?

Is that why the assembly manager and machine configuration file are loading from framework\v2.0.50727\ and not from \Framework64\v4.0.30319\?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一曲琵琶半遮面シ 2024-10-03 11:46:29

原因是 Open XML SDK 2,我避免使用 Open XML SDK 2,而我的 AddIn 现在工作正常。使用 Microsoft Interop 从头开始​​重建我的项目来读取/写入 Microsoft Office 2010 文档。

问题是没有太多文档可供开发人员阅读。我自己完成了阅读文章并解决问题的繁重工作。

希望其他人不必面临同样的考验。

Open XML SDK 2 was the cause, I avoided Open XML SDK 2 and my AddIn works perfectly now. Rebuilt my project from scratch using Microsoft Interop to read/write Microsoft Office 2010 documents.

Issue is that there is not much documentation around for developers to read. I've done the grunt work reading articles and figuring out the problem myself.

Hopefully others would not have to face the same ordeal.

谈情不如逗狗 2024-10-03 11:46:29

看看下面的链接也许会有所帮助... 如何创建自定义安装程序

它对我有帮助,我有一个有点类似的场景(Word 2010 Addin + Open XML SDK 2.0 - 部署在从 Windows XP Service Pack 3 32 位到 Windows 7 Professional 64 位运行的计算机上)。

希望对您有帮助。

See maybe the following link will help... How to create a custom install program.

It helped me, and I had a somewhat similar scenario (a Word 2010 Addin + Open XML SDK 2.0 - deployed on machine running from Windows XP Service Pack 3 32 bit to Windows 7 Professional 64 bit).

Hope it helps you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文