如何找到作为资源包含在 outlook 加载项中以与 DllImport 一起使用的 DLL 的位置
How can I find the location of DLLs included as resources in an outlook add-in for use with DllImport
我有一个 outlook 加载项,我需要在其中使用 DllImport 加载自定义 dll。我已将 dll 包含在项目资源中,当项目 'published' 时,它被复制到 Resources 文件夹。
我的问题是,在用户安装插件后,我不知道资源中包含的 DLL 在哪里。如果我知道,那么我可以将该位置添加到当前搜索路径,一切都会正常进行。
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory);
有人有解决方案吗?还是我的做法全错了?
//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;
DllLocation = Path.Combine(directory, "Resources\MyDll.dll");
我有一个 outlook 加载项,我需要在其中使用 DllImport 加载自定义 dll。我已将 dll 包含在项目资源中,当项目 'published' 时,它被复制到 Resources 文件夹。
我的问题是,在用户安装插件后,我不知道资源中包含的 DLL 在哪里。如果我知道,那么我可以将该位置添加到当前搜索路径,一切都会正常进行。
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory);
有人有解决方案吗?还是我的做法全错了?
//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;
DllLocation = Path.Combine(directory, "Resources\MyDll.dll");