卸载我的 Office 2010 插件会留下空指针异常
我一直在试图找出为什么我的Office2010插件在卸载过程中会留下空指针异常,而2007版本则不会。 (编辑:2007 年与 2010 年处于相同状态 - 失败)
为了缩小范围,我放入了几个事件日志陷阱,这意味着如果代码到达此点 - 我应该在事件日志中获取一些内容。没有这样的运气。现在,要么我错误地编写了事件日志陷阱,要么代码没有达到这一点。
在 CustomSetupActions - ClickOnceInstaller.cs 中
public void Uninstall(System.Collections.IDictionary savedState)
{
// write something to eventlog
// This is not being fired, the exception doesn't reach here or writing to eventlog fails.
if (!EventLog.SourceExists("OfficePlugin"))
{
EventLog.CreateEventSource("OfficePlugin", "Application");
}
EventLog.WriteEntry
("OfficePlugin"
, string.Format("Uninstalling: (bug hunting)"), EventLogEntryType.Information);
string deploymentLocation = (string)savedState["deploymentLocation"];
if (deploymentLocation != null)
{
string arguments = String.Format(
"/S /U \"{0}\"", deploymentLocation);
ExecuteVSTOInstaller(arguments);
}
}
,至于 ExecuteVSTOInstaller(string argument)
2007 指的是: string subPath = @"Microsoft Shared\VSTO\9.0\VSTOInstaller.exe";
2010 指的是: string subPath = @"Microsoft Shared\VSTO\10.0\VSTOInstaller.exe";
如果第一个陷阱已触发,这就是我之后放置陷阱的位置。
--
我有另一种方法来处理注册数据库
RegisterOffice2010AddIn.cs
public void UnRegisterAddIn(string applicationName, string addInName)
{
下一行与我刚刚使用/显示的事件日志陷阱完全相同。
两者之间的差异(2007 年与 2010 年)。
private const string UserSettingsLocation =
@"Software\Microsoft\Office\12.0\User Settings";
vs
private const string UserSettingsLocation =
@"Software\Microsoft\Office\14.0\User Settings";
我想不出还有什么地方可以放置陷阱。 之外,它不执行任何操作
我有一个 CustomInstaller,除了 Dispose(bool dispose)
和 InitializeComponent()
开发
: <块引用>行动开始时间 14:21:00:PublishFeatures。
活动于 14:21:00 结束:PublishFeatures。返回值1。
操作开始时间 14:21:00:PublishProduct。
行动于 14:21:00 结束:PublishProduct。返回值1。
操作开始时间 14:21:00:InstallExecute。
MSI (c) (B8:BC) [14:21:01:013]:字体已创建。字符集:Req=0,Ret=0,字体:Req=MS Shell Dlg,Ret=MS Shell Dlg错误1001。错误1001。卸载时发生异常。该异常将被忽略并继续卸载。但是,卸载完成后,应用程序可能无法完全卸载。 -->未将对象引用设置为对象的实例。
调试:错误 2769:自定义操作 _EE8A0D36_BE55_421F_9A55_95470C001D87.uninstall 未关闭 1 个 MSIHANDLE。
安装程序在安装此软件包时遇到意外错误。这可能表明此包有问题。错误代码为 2769。参数为:_EE8A0D36_BE55_421F_9A55_95470C001D87.uninstall, 1,
操作于 14:21:05 结束:InstallExecute。返回值3.
操作于 14:21:06 结束:安装。返回值3。
谷歌搜索错误 2769 - 给出答案“[TARGETDIR]\”,但我没有引用 TargetDir,我引用了DeploymentLocation。是的,我尝试将“\”添加到我能想到的地方。包括设置 - 注册表 - HKLM\Software\MS\Office\12.0\ ...etc...\Addins\Excel/Word/Outlook 和 Manifest 键值。没有提供任何反馈,无论好坏,错误或其他。我不知道还有什么办法可以追捕这个人。
我猜它在 VDPROJ 中引用了这一点:
<块引用>{
“名称”=“8:UnregisterOutlookAddIn”
“条件”=“8:”
“对象”=“8:_73E71A44EB72485AB7367745F7D57F49”
“文件类型”=“3:1”
“安装操作”=“3:4”
“参数”=“8:”
“入口点”=“8:”
“序列”=“3:3”
“标识符”=“8:_EE8A0D36_BE55_421F_9A55_95470C001D87”
“InstallerClass”=“11:TRUE”
"CustomActionData" = "8:/addinName=\"OUR.Outlook.Outlook2010AddIn\" /application=\"Outlook\""
}
它抛出两个异常 - CustomSetupActions 和 UnregisterAddIn 下的次要异常以及 ClickOnceInstaller 和 Uninstall 下的主要异常。我为什么将它们称为第二和主要。那么它会在 CustomAction 中执行异常,然后在 ClickOnce 中执行终止操作。我已经消除了 CustomActions 中的一个,现在只需担心 ClickOnce。据我所知,ClickOnce 实现了安装项目中指定的接口(安装、回滚、提交、卸载)。我只需要弄清楚它如何在卸载方法中运行错误。
免责声明:当然,除非我弄错了并且找错了树。
I've been trying to track down why my Office2010 plugin leaves a null pointer exception during uninstall and the 2007 version does not. (Edit: 2007 is at same state as 2010 - FAIL)
To narrow it down I have put in a couple of eventlog traps, meaning if code reaches this point - I should get something in the Eventlog. No such luck. Now either I written the eventlog trap wrong or code doesn't reach that point.
In the CustomSetupActions - ClickOnceInstaller.cs
public void Uninstall(System.Collections.IDictionary savedState)
{
// write something to eventlog
// This is not being fired, the exception doesn't reach here or writing to eventlog fails.
if (!EventLog.SourceExists("OfficePlugin"))
{
EventLog.CreateEventSource("OfficePlugin", "Application");
}
EventLog.WriteEntry
("OfficePlugin"
, string.Format("Uninstalling: (bug hunting)"), EventLogEntryType.Information);
string deploymentLocation = (string)savedState["deploymentLocation"];
if (deploymentLocation != null)
{
string arguments = String.Format(
"/S /U \"{0}\"", deploymentLocation);
ExecuteVSTOInstaller(arguments);
}
}
As for the ExecuteVSTOInstaller(string arguments)
2007 refers to: string subPath = @"Microsoft Shared\VSTO\9.0\VSTOInstaller.exe";
2010 refers to: string subPath = @"Microsoft Shared\VSTO\10.0\VSTOInstaller.exe";
If the first trap had fired, this is where I would have placed the trap afterwards.
--
I have another method that handles the registration db
RegisterOffice2010AddIn.cs
public void UnRegisterAddIn(string applicationName, string addInName)
{
Next line is precisely the same eventlog trap as I just used/shown.
Difference between the two (2007 vs 2010).
private const string UserSettingsLocation =
@"Software\Microsoft\Office\12.0\User Settings";
vs
private const string UserSettingsLocation =
@"Software\Microsoft\Office\14.0\User Settings";
I can't think of any other place that might be interesting to place the trap. I have a CustomInstaller which doesn't do anything besides Dispose(bool disposing)
and InitializeComponent()
Development:
Action start 14:21:00: PublishFeatures.
Action ended 14:21:00: PublishFeatures. Return value 1.
Action start 14:21:00: PublishProduct.
Action ended 14:21:00: PublishProduct. Return value 1.
Action start 14:21:00: InstallExecute.
MSI (c) (B8:BC) [14:21:01:013]: Font created. Charset: Req=0, Ret=0, Font: Req=MS Shell Dlg, Ret=MS Shell DlgError 1001. Error 1001. An exception occurred while uninstalling. This exception will be ignored and the uninstall will continue. However, the application might not be fully uninstalled after the uninstall is complete. --> Object reference not set to an instance of an object.
DEBUG: Error 2769: Custom Action _EE8A0D36_BE55_421F_9A55_95470C001D87.uninstall did not close 1 MSIHANDLEs.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: _EE8A0D36_BE55_421F_9A55_95470C001D87.uninstall, 1,
Action ended 14:21:05: InstallExecute. Return value 3.
Action ended 14:21:06: INSTALL. Return value 3.
Googling the Error 2769 - gives an answer of "[TARGETDIR]\" , but I dont reference TargetDir, I reference deploymentLocation. And Yes I have tried adding the "\" to places I could think of. Including the setup - Registry - HKLM\Software\MS\Office\12.0\ ...etc... \Addins\Excel/Word/Outlook and the Manifest keyvalue. Gave no feedback, good or bad, errors or otherwise. I'm at a loss what else to try to hunt this one down.
I have a guess it is referencing to this, in the VDPROJ:
{
"Name" = "8:UnregisterOutlookAddIn"
"Condition" = "8:"
"Object" = "8:_73E71A44EB72485AB7367745F7D57F49"
"FileType" = "3:1"
"InstallAction" = "3:4"
"Arguments" = "8:"
"EntryPoint" = "8:"
"Sequence" = "3:3"
"Identifier" = "8:_EE8A0D36_BE55_421F_9A55_95470C001D87"
"InstallerClass" = "11:TRUE"
"CustomActionData" = "8:/addinName=\"OUR.Outlook.Outlook2010AddIn\" /application=\"Outlook\""
}
I found it throws two exception - the secondary under CustomSetupActions and UnregisterAddIn and the primary under ClickOnceInstaller and Uninstall. Howcome I mention them as 2ndary and primary. Well it will do the exception in CustomAction and then the killing one in ClickOnce. I've eliminated the one in CustomActions and I now only have to worry about the ClickOnce. From what I can gather the ClickOnce implements the interface specified in the Setup Project (Install, Rollback, Commit, Uninstall). I only have to figure out how it can run amiss the Uninstall method.
Disclaimer: Unless ofcourse I'm mistaken and is barking up the wrong tree.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改为 WiX。它成为一种解决方法,因为原始方法仍然有效。
Change to WiX. It became a workaround as the original is still true.