C# Office(Outlook)加载项和EXE文件
我在Visual Studio 2012中编写了一个Outlook插件,需要它来运行.exe文件 问题是:当我将.exe添加到项目中时,它会将其放在bin\debug或bin\release文件夹中。 但是,插件从Office文件夹运行,因此它与我的.exe文件没有连接C# Office(Outlook)加载项和EXE文件,c#,visual-studio,outlook,ms-office,C#,Visual Studio,Outlook,Ms Office,我在Visual Studio 2012中编写了一个Outlook插件,需要它来运行.exe文件 问题是:当我将.exe添加到项目中时,它会将其放在bin\debug或bin\release文件夹中。 但是,插件从Office文件夹运行,因此它与我的.exe文件没有连接 如何执行此操作?您的加载项从Office文件夹运行?你确定这就是安装它的地方吗?还是因为您正在检索主机应用程序的位置,即outlook.exe?要检索外接程序的位置,请使用类似以下内容: //use CodeBase inste
如何执行此操作?您的加载项从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;
你完全正确!我检查了当前目录。。。谢谢