基于Net 4.0 VS2010的VSTO插件,必须加载混合模式组件 [英] Net 4.0 VS2010 based VSTO addin that has to load mixed-mode assemblies

查看:63
本文介绍了基于Net 4.0 VS2010的VSTO插件,必须加载混合模式组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将VS2008,.Net 3.5中的Word(Office 2007)应用程序插件迁移到VS2010和Net 4.0。 在运行时,我们的.Net 4.0程序集使用第三方程序集来加载本机代码。  第三方程序集是用Net  2.0  构建的。
此时我得到的是"混合模式程序集是针对v2运行时构建的,无法加载到v4运行时"。异常消息。  

I am migrating a Word (Office 2007) application addin from VS2008, .Net 3.5 to VS2010 and Net 4.0.  During runtime our .Net 4.0 assembly uses a 3rd party assembly to load native code.   The 3rd party assembly is built with Net 2.0   At that point I'm getting the "Mixed mode assembly is built against v2 runtime and cannot be loaded into the v4 runtime." exception message.  

此问题的回应是添加

useLegacyV2RuntimeActivationPolicy = true

useLegacyV2RuntimeActivationPolicy=true

到< startup>配置文件的配置部分。  我们可以更新VSTO插件程序集app.config,但看起来没有任何效果,因为必须更改进程级别的配置。  对于Office插件,我们不能
更改winword。 exe进程配置文件。 可能有其他VSTO插件加载到同一个Office进程中。

to the <startup> configuration section of the config file.   We can update the VSTO addin assembly app.config, but that appears not to have any effect as the config at the process level has to be changed.  For Office addins, we cannot change the winword.exe process configuration file.  There may be other VSTO addins that load into the same Office process.

那么基于VSTO的解决方案应如何处理此问题? 有人有解决方案吗?

So how are VSTO based solutions supposed to deal with this issue?  Anyone have a solution?

 

推荐答案

Hello Brian,

Hello Brian,

useLegacyV2RuntimeActivationPolicy应该在应用程序级配置文件中工作。因此,要解决原始问题,我们必须添加包含配置的配置文件并将其部署到Office安装文件夹。

The useLegacyV2RuntimeActivationPolicy is supposed to work in the application level config file. So to resolve the original issue, we have to add a config file contains the configurations and deploy it to Office installed folder.

实际上,根据我的理解,useLegacyV2RuntimeActivationPolicy允许混合模式运行时,所以它不应该影响其他插件。

Actually, based on my understanding, the useLegacyV2RuntimeActivationPolicy allows the mixed mode runtime, so it should not affect other Addins.

 

祝你好运,

Ji Zhou

 


这篇关于基于Net 4.0 VS2010的VSTO插件,必须加载混合模式组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆