Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Office(Outlook)加载项和EXE文件_C#_Visual Studio_Outlook_Ms Office - Fatal编程技术网

C# Office(Outlook)加载项和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

我在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;

你完全正确!我检查了当前目录。。。谢谢