卸载wordxp的PIA(完全解析)

来源:互联网 发布:yum y install lrzsz 编辑:程序博客网 时间:2024/04/28 07:26

   在.net 2.0下,如果想支持对多word版本的支持,就要装,不同的pia,可是wordxp尤其惹人烦,一但装上就不能卸载,为什么要卸载xp的Pia呢?

   应为Word.Application 与word.ApplicationClass在Xp的pia下是不能相互转换的,可是有些word事件是一定要在ApplicationClass下才可以被调用的。如果一但装上WordXp的PIA那么以后,你可能编写的word2000,word2003下的程序就要出错了,这时就要想到卸载wordxp的PIA了,那么下面我们开始找办法卸载她!

1、首先就是看看,wordxp,在安装的时候注册了点什么

 

echo off

echo Microsoft Office XP Primary Interop Assemblies Registration Utility
echo Copyright (c) 
2002 Microsoft(R) Corporation. All rights reserved.
echo Note: This utility must be run from the Visual Studio .NET Command Prompt. It will not function properly otherwise.
echo Start adding primary interop assemblies to the 
global assembly cache.

echo on

gacutil 
-i Microsoft.Office.Interop.Access.dll
gacutil 
-i adodb.dll
gacutil 
-i dao.dll
gacutil 
-i Microsoft.Office.Interop.Excel.dll
gacutil 
-i Microsoft.Office.Interop.FrontPage.dll
gacutil 
-i Microsoft.Office.Interop.FrontPageEditor.dll
gacutil 
-i Microsoft.Office.Interop.Graph.dll
gacutil 
-i Microsoft.Office.Interop.Visio.dll
gacutil 
-i mscomctl.dll
gacutil 
-i msdatasrc.dll
gacutil 
-i Microsoft.Office.Interop.SmartTag.dll
gacutil 
-i office.dll
gacutil 
-i Microsoft.Office.Interop.Outlook.dll
gacutil 
-i Microsoft.Office.Interop.OutlookViewCtl.dll
gacutil 
-i Microsoft.Office.Interop.Owc.dll
gacutil 
-i Microsoft.Office.Interop.PowerPoint.dll
gacutil 
-i Microsoft.Office.Interop.Publisher.dll
gacutil 
-i stdole.dll
gacutil 
-i Microsoft.Vbe.Interop.dll
gacutil 
-i Microsoft.Office.Interop.Word.dll

echo off

echo End adding assemblies to the 
global assembly cache.

echo Start adding registry entries 
for each primary interop assembly.

echo on

regedit 
/s Microsoft.Office.Interop.Access.dll.reg
regedit 
/s adodb.dll.reg
regedit 
/s dao.dll.reg
regedit 
/s Microsoft.Office.Interop.Excel.dll.reg
regedit 
/s Microsoft.Office.Interop.FrontPage.dll.reg
regedit 
/s Microsoft.Office.Interop.FrontPageEditor.dll.reg
regedit 
/s Microsoft.Office.Interop.Graph.dll.reg
regedit 
/s Microsoft.Office.Interop.Visio.dll.reg
regedit 
/s mscomctl.dll.reg
regedit 
/s msdatasrc.dll.reg
regedit 
/s Microsoft.Office.Interop.SmartTag.dll.reg
regedit 
/s office.dll.reg
regedit 
/s Microsoft.Office.Interop.Outlook.dll.reg
regedit 
/s Microsoft.Office.Interop.OutlookViewCtl.dll.reg
regedit 
/s Microsoft.Office.Interop.Owc.dll.reg
regedit 
/s Microsoft.Office.Interop.PowerPoint.dll.reg
regedit 
/s Microsoft.Office.Interop.Publisher.dll.reg
regedit 
/s stdole.dll.reg
regedit 
/s Microsoft.Vbe.Interop.dll.reg
regedit 
/s Microsoft.Office.Interop.Word.dll.reg

echo off

echo End adding registry entries 
for each primary interop assembly.

echo Operation complete.

echo on

里面分两步,第一是用“gacutil -i Microsoft.Office.Interop.Access.dll”引用dll,第二就是注册注册表信息

那么我们来想解决办法:

首先,用“gacutil -u ”来卸载这些dll是最方便的,如果用来删除注册信息的注册键,工作是比较浩大的,所以我的道选是用“gacutil -u ”来卸载dll,可是执行完以为发现失败了,其实在执行时gacutil 时,他们是找不到这个命令的。所以其实这些dll开始就没有被注册进去。残念.....

在Visual Studio 2005 命令提示找执行gacutil 是没有问题的,可是卸载又出了问题,所以从dll上下手是错误的了。

2、就是重装word,让2000或2003在安装的时候还原这些环境,结果又以失败告终;

3、重装.net2.0,来还原这些环境,结果又以失败告终;

试过多种方法发现,只要是装过wordxp的pia后就不要妄想通过后期绑定的方式进行操作word了,应为他改写了word的com与.net的application,applicationClass的映射。除非重装系统,不过值得庆幸的是,装word2003,还是可以后期绑定的。所以,卸载wordxp的pia宣告失败。