gpt4 book ai didi

c# - 卸载我的 Office 2010 插件会留下空指针异常

转载 作者:太空宇宙 更新时间:2023-11-03 16:47:01 25 4
gpt4 key购买 nike

我一直在试图找出为什么我的 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 arguments)

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";

对比

    private const string UserSettingsLocation =
@"Software\Microsoft\Office\14.0\User Settings";

我想不出还有什么地方可以放置陷阱。我有一个 CustomInstaller,它除了 Dispose(bool disposing)InitializeComponent()

什么都不做

发展:

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 Dlg

Error 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.

谷歌搜索错误 2769 - 给出了“[TARGETDIR]\”的答案,但我没有引用 TargetDir,我引用了 deploymentLocation。是的,我已经尝试将“\”添加到我能想到的地方。包括设置 - 注册表 - HKLM\Software\MS\Office\12.0\...等...\Addins\Excel/Word/Outlook 和 list 键值。不提供任何反馈,无论好坏,错误或其他。我不知道还有什么可以尝试追捕这个。

我猜它在 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\""
}

我发现它抛出两个异常 - CustomSetupActions 和 UnregisterAddIn 下的次要异常以及 ClickOnceInstaller 和 Uninstall 下的主要异常。为什么我提到它们是第二和主要的。那么它将在 CustomAction 中执行异常,然后在 ClickOnce 中执行异常。我已经消除了 CustomActions 中的那个,现在我只需要担心 ClickOnce。据我所知,ClickOnce 实现了安装项目中指定的接口(interface)(安装、回滚、提交、卸载)。我只需要弄清楚它是如何运行在 Uninstall 方法之外的。

免责声明:当然,除非我弄错了并且找错了树。

最佳答案

更改为 WiX。它成为一种解决方法,因为原来的仍然是正确的。

关于c# - 卸载我的 Office 2010 插件会留下空指针异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5578098/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com