Outlook VSTO 加载项 - 加载错误 80080005
Outlook VSTO Add-in - Load Error 80080005
我有一个 Outlook 加载项,它工作正常。但是,在加载 Outlook 时,我的加载项关闭并且出现错误
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
有我的插件加载代码
Explorer thisExplorer;
public static Outlook.Application application;
Logger _logger = LogManager.GetCurrentClassLogger();
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
if (AppConfig.LoadConfigurations())
{
string nlogConfigFile = AppConfig.GetConfig<string>("NLogConfig");
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(nlogConfigFile, true);
_logger.Info("***************************NEW SESSION*******************************");
//
application = new Outlook.Application();
/*
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("OUTLOOK");
int collCount = processes.Length;
if (collCount != 0)
{
// Outlook already running, hook into the Outlook instance
application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
}
else
{
application = new Outlook.Application();
}
*/
thisExplorer = Application.ActiveExplorer();
thisExplorer.SelectionChange += new ExplorerEvents_10_SelectionChangeEventHandler(ApplicationExplorer_SelectionChanged);
}
else
{
MessageBox.Show("Failed to load configurations");
}
}
正如我在代码中所写,我根据
注释掉了 Outlook 进程计数
取消注释会导致另一个错误
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
加载 Outlook 后,我通过菜单启用加载项,效果非常好。
那么,我该如何解决加载问题?
谢谢大家
不要创建 Outlook.Application
对象的新实例(无论如何它都会被安全补丁削弱) - 你免费获得该对象:使用 Globals.ThisAddIn.Application
.
我有一个 Outlook 加载项,它工作正常。但是,在加载 Outlook 时,我的加载项关闭并且出现错误
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
有我的插件加载代码
Explorer thisExplorer;
public static Outlook.Application application;
Logger _logger = LogManager.GetCurrentClassLogger();
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
if (AppConfig.LoadConfigurations())
{
string nlogConfigFile = AppConfig.GetConfig<string>("NLogConfig");
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(nlogConfigFile, true);
_logger.Info("***************************NEW SESSION*******************************");
//
application = new Outlook.Application();
/*
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("OUTLOOK");
int collCount = processes.Length;
if (collCount != 0)
{
// Outlook already running, hook into the Outlook instance
application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
}
else
{
application = new Outlook.Application();
}
*/
thisExplorer = Application.ActiveExplorer();
thisExplorer.SelectionChange += new ExplorerEvents_10_SelectionChangeEventHandler(ApplicationExplorer_SelectionChanged);
}
else
{
MessageBox.Show("Failed to load configurations");
}
}
正如我在代码中所写,我根据
取消注释会导致另一个错误
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
加载 Outlook 后,我通过菜单启用加载项,效果非常好。
那么,我该如何解决加载问题?
谢谢大家
不要创建 Outlook.Application
对象的新实例(无论如何它都会被安全补丁削弱) - 你免费获得该对象:使用 Globals.ThisAddIn.Application
.