我在 Visual Studio 2012 中编写了一个 Outlook 插件,我需要它来运行 .exe 文件。
问题是:当我将 .exe 添加到项目中时,它会将其放入 bin\debug 或 bin\release 文件夹中。 但是,该插件从 Office 文件夹运行,因此它与我的 .exe 文件没有连接。
这应该如何完成?
最佳答案
您的插件从 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;
关于c# - Office (Outlook) 插件和 EXE 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26100969/