【发布时间】:2016-10-03 22:03:06
【问题描述】:
我正在尝试创建一个 Outlook 2013 插件,它将从指定位置加载其他托管插件。基本上是一个加载程序存根,它知道如何找到这些其他插件、加载它们的程序集并注册。
这是一个简单的概念证明:
using System;
using System.Linq;
using System.Windows.Forms;
using System.ComponentModel;
using System.Reflection;
using Microsoft.Office.Tools;
using Microsoft.Office.Core;
using Microsoft.Office.Tools.Ribbon;
[Microsoft.VisualStudio.Tools.Applications.Runtime.StartupObject(0)]
public class TestAddin : IAddInExtension, IExtension, EntryPoint, ISupportInitialize, IComponent, IDisposable, IBindableComponent
{
private List<EntryPoint> entrypoints = new List<EntryPoint>();
public TestAddin(Factory factory, IServiceProvider serviceProvider)
{
Assembly asm = LoadAddinAssembly();
foreach (var type in asm.GetTypes())
{
var attr = type.GetCustomAttributes(false).OfType<Microsoft.VisualStudio.Tools.Application.Runtime.StartupObjectAttribute>().FirstOrDefault();
if (attr != null)
{
var ep = Activator.CreateInstance(
type, factory, serviceProvider)
as Microsoft.Office.Tools.EntryPoint;
if (ep != null)
{
entrypoints.Add(ep);
}
}
}
}
public void BeginInit()
{
foreach (var inst in entrypoints)
inst.BeginInit();
}
// Implement the rest of the interface methods similar to BeginInit above
}
Outlook 构建我的类,我的类加载另一个插件程序集并创建入口点,然后 Outlook 调用以下 3 个直通方法,然后我调用其他插件:
它们都不会产生任何错误,但在那之后,任何传递方法都不会被调用,而且我尝试加载的插件也不会做任何事情。
我需要通过的向 Outlook 公开的官方插件是什么?或者甚至有可能做这样的事情?
【问题讨论】:
标签: c# .net outlook office-interop outlook-addin