【问题标题】:Office (Outlook) AddIn and EXE fileOffice (Outlook) 加载项和 EXE 文件
【发布时间】:2014-09-29 13:21:48
【问题描述】:

我在 Visual Studio 2012 中编写了一个 Outlook 插件,我需要它来运行一个 .exe 文件。

问题是:当我将 .exe 添加到我的项目时,它会将其放在 bin\debug 或 bin\release 文件夹中。 但是,插件从 Office 文件夹中运行,因此它与我的 .exe 文件没有连接。

这应该怎么做?

【问题讨论】:

    标签: c# visual-studio outlook ms-office


    【解决方案1】:

    您的插件从 Office 文件夹运行?你确定这是安装它的地方吗?还是因为您正在检索主机应用程序的位置(可能是 Outlook.exe)?要检索插件的位置,请使用以下内容:

    //use CodeBase instead of Location because of Shadow Copy.
    string codebase = Assembly.GetExecutingAssembly().CodeBase;
    var vUri = new UriBuilder(codebase);
    string vPath = Uri.UnescapeDataString(vUri.Path + vUri.Fragment);
    string directory = Path.GetDirectoryName(vPath);
    if (!string.IsNullOrEmpty(vUri.Host)) directory = @"\\" + vUri.Host + directory;
    

    【讨论】:

    • 你完全正确!我检查了 currentDirectory... 谢谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多