1

I am trying to add third party lib to my Outlook 2013 adding written in C#. It consists from 2 components: .Net wrapper and C++ dll itself.

I have referenced .net wrapper in the adding project and added C++ lib as a copy on build resource.

Apparently, Office runtime puts every .Net lib referenced by a plugin in a separate folder excluding C++ lib as it not referenced. And plugin fails to locate C++ lib because it should be in a same folder with the executing dll.

Sample plugin’s dll location :

C:\Users\UserName\AppData\Local\assembly\dl3\TMGBBYEC.3JC\QE21JQR6.YRW\4a3206fe\4acfc661_ccc6cf01\SomeLibName.dll

Any ideas how to fix this?

v00d00
  • 3,215
  • 3
  • 32
  • 43

1 Answers1

1

Try something like the following to figure out the dll location.

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;
Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Thanks I was using Location property on the assembly, was probably receiving GAC'ish location of it. In the reality addin was referenced from bin/debug, checking installed version. – v00d00 Sep 02 '14 at 20:19
  • And installed version also targetting installation folder. Ok it is clear that c++ lib is the source of pain, as we have managed to add Sqlite native libs fine... – v00d00 Sep 02 '14 at 20:29