-2

I checked prior posts like How do I prevent the app.config from being integrated into a .net Library (dll)

but these did not help me with my situation.

I am having trouble keeping my Outlook addin app.config not compiled into the dll. I assume it's being compiled, as when it first loads I ask the application to show me the path of its configuration file using:

MessageBox.Show(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile.ToString());

This returns a path for a file at

C:\Users\...\AppData\ [random name]\outlookadddin.config

instead of using the app.config which is located in the same folder as the the dll itself.

Can I force configuration manager to refer to the dll in the same folder as the assembly rather than creating one of its own?

UPDATE: after finding this: how do I make my application read the application config instead of machine.config?

it seems to partially advance a solution, shortly explained, its a known issue with VSTO being deployed via ClickOnce \ MSI. you need to add |VSTOLOCAL to the registery manifest key path.

Problem im facing now, is that if i install my addin on a Network drive, using |VSTOLOCAL it simply won't load, removing |VSTOLOCAL and it works like a charm. any ideas ?

Community
  • 1
  • 1
Stavm
  • 7,833
  • 5
  • 44
  • 68
  • 1
    Unclear what you mean - first of all, no `app.config` ever gets *compiled* or integrated into a DLL - and second of all, the `app.config` is a design-time only file - it gets renamed into `(yourproject).exe.config` or `yourproject.dll.config` at compile time. – marc_s Feb 28 '15 at 16:55
  • Thank you for commenting. and yes, it is, but for some reason my project.dll.config file which is located in the same folder as the assembly, isn't being used, it is being sent to the \bin\release folder, but i can simply remove it the application just seems to ignore it all together, and create its own copy of the config file, in a random location under ..\users\appdata\[...]\project.dll.config – Stavm Feb 28 '15 at 16:59
  • That is **standard .NET** config behavior - the configs of DLLs are never used, you have to add your config to the **hosting application** (e.g. your main app, or your web site) – marc_s Feb 28 '15 at 17:00
  • so you're basically saying my only way to use the dll's config file is to name it Outlook.exe.config and place it in the office folder ? – Stavm Feb 28 '15 at 17:02
  • Or you need to explicitly load an arbitrarily named config on your own (using `ConfigurationManager.OpenMappedExeConfiguration) and then roll your own (see MSDN docs for details) – marc_s Feb 28 '15 at 17:04
  • Thank you for commenting @marc_s, it seems its a known issue with VSTO 4.0, one must add a |vstolocal to the manifest registry key – Stavm Feb 28 '15 at 18:08
  • You need to install add-ins locally. I don't think networks locations are supported. – Eugene Astafiev Feb 28 '15 at 19:21

1 Answers1

1

OK i finally found an answer to this: it appears since vsto 4.0 - you MUST have |vstolocal at the end of the manifest registry key for it to use the .config file from the folder and not from the cache.

My issue was solved by adding |VSTOLOCAL to the regkey, but since i want the addin dll to be placed on a NETWORK drive, this caused trust issues with outlook, which for some reason appearse to be not supporting network drive-installed addins by default.

These were solved by adding this registry key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\vsto runtime Setup\v4]
"EnableVSTOLocalUNC"=dword:00000001

Everything works well now. Thanks everyone.

Stavm
  • 7,833
  • 5
  • 44
  • 68