03 与 07 多用户 的部署区别

April 15, 2008 7:04 PM
Misha Shneerson said:

Office 2003 does not display HKLM registered add-ins in COM add-ins dialog. So, the fact that these do not show up does not indicate they HKLM add-ins did not load. Typically, to deploy to HKLM on Office 2003 - I would just move all the registry keys from HKCU to HKLM and modify the SetSecurity to run caspol for machine level policy.

What happens under the cover?

VSTO SE AddIn loader is implemented by AddinLoader.dll - this is a native DLL that knows how to handle instantiation of VSTO add-ins as if those were regular COM objects. Hint: to check whether Office 2003 picked up your addin you can check whether AddinLoader.dll has been loaded (use process explorer from sysinternals.com or just a regular native debugger to see which modules are loaded). When AddInLoader.dll is loaded into the process it has no idea whether it was registered from HKLM or HKCU. Instead, the only information it gets is the GUID of the COM Add-In. Given this information it always tries to find the .manifest file (which has information about assemblies that need to be loaded) by combinining the ManifestLocation and ManifestName registry values from HKCR/CLSID/{-- GUID ---}/InProcServer32. Note that HKCR is not a real registry hive - instead it is just a virtual merge of HKLM/Software/Classes and HKCU/Software/Clases.

Once .manifest file is found - AddInloader would try and load the assemblies specified in the manifest.

From this point on the loading failures can be seen using VSTO_SUPPRESSDISPLAYALERTS environment variable.

As you can see there are multiple points of failure that can result from incorrect registration and you really need to follow the entire chain to understand what might be going on in your case. Additional points of failure are: add-in might have been soft-disabled - LoadBehavior was reset to 2, add-in might have been killed and have been hard-disabled - check the Help->About -> Disabled Items ... .

If you have further questions to do hesitate to contact me using the email link at the top right corner of this page.
# April 15, 2008 7:58 PM
office2003没有显示出HKLM下注册的add-ins com程序。但是,事实上,这并不能说明HKLM下注册的add-ins并没有加载。部署office2003,我将注册表中的HKCU的所有值放到HKLM中去,并且将 SetSecurit中 caspol命令的用户模式修改为machine模式就可以了。
这种做法可行的原因是什么呢?
VSTO第二版下的程序加载是以依赖于AddinLoader.dll。这是一个原生的DLL,它会加载那些符合规则的VSTO add-ins程序。所以,检查OFFICE2003有没有加载你的addin,你就可以去检查AddinLoader.dll有没有被加载。(用sysinternals.com网站下的process explorer,或者使用一个正规的debugger 去检查哪些模块被加载了。)当一个AddInLoader.dll被加载,它并不关心是注册在HKLM 还是 HKCU下,它需要的唯一一点是这个COM Add-In的GUID号。 得到这个GUID后,就开始试图通过 HKCR/CLSID/{-- GUID ---}/InProcServer32中的值查询Manifest地址和Manifest名称,去查询.manifest文件(其中含有需要被加载的程序集信息)。HKCR并不是个真正的注册表值,它只是HKLM/Software/Classes和HKCU/Software/Clases合并的的虚拟值。
一旦.manifest文件被找到,就开始加载manifest文件中被描述的程序集了。
使用VSTO_SUPPRESSDISPLAYALERTS的环境变量可以查询出装在失败的程序。
不正确的注册表值能引起很多种情况的错误,你可以理解整篇文章,检查你的具体情况。另外,导致失败的原因还有:LoadBehavior可能被重置为2,导致add-in不可用;add-in可能被杀掉,被强制不可用,检查Help->About -> Disabled Items ...

 

所以:

1、03用guid识别。将vsto自带俺装的注册表中currentUser部分的全部 放入 machine中。currentUser删除即可。
2、07 用网页中说的方法。

你可能感兴趣的:(instantiation,office,dll,file,merge,idea)