VSTO Assembly解决问题 [英] VSTO AssemblyResolve issue

查看:100
本文介绍了VSTO Assembly解决问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们为Word开发了一个VSTO插件,但问题是该插件的最早入口是AddIn_Startup处理程序.问题在于,对于为实现所需的程序集而实施的AssemblyResolve处理程序,调用此处理程序为时已晚.

We develop a VSTO plugin for Word and we have the problem that the earliest entry point of the addin is the AddIn_Startup handler. The issue is that this handler is called too late for the AssemblyResolve handler we implemented to find the needed assemblies.

我通过将处理程序分配给Addins.Designer.cs类中的AppDomain.CurrentDomain.AssemblyResolve事件来解决该问题,但是众所周知,此代码是自动生成的.

I sovled the problem by assigning the handler to the AppDomain.CurrentDomain.AssemblyResolve event in the Addins.Designer.cs class, but as you all know, this code is autogenerated.

是否有一种方法可以像在AddIn_Startup处理程序中以及在非自动生成的文件中一样尽快分配AssemblyResolve处理程序?

Is there a way to assign the AssemblyResolve Handler sooner as in the AddIn_Startup handler and in a not autogenerated file?

推荐答案

我刚刚遇到了这个问题,从搜索中落入此处,然后环顾了

I have just had this problem, landed here from searching and then had a look around the VSTO Microsoft.Tools AddinBase Class (I hope this is the right link). In any case I am Overriding the Begininit and setting AppDomain.CurrentDomain.AssemblyResolve there. For my case this is early enough to load my reference.

但是,请注意,如果需要,该插件仍可以尝试加载您的程序集(并失败),并且甚至可以在Begininit之前发生.例如,如果您在ThisAddin类中从程序集中引用枚举或常量.

However, please note that the addin can still try to load your assembly (and fail) if it needs it and this can happen even before Begininit. For example if you refer to an Enum or Const from your Assembly in the ThisAddin class.

这篇关于VSTO Assembly解决问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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