how do I make my application read the application config instead of machine.config?
Asked Answered
E

3

6

I have an word add in application created in c# which is accessing a web service and is perfectly working if installed outside Program Files folder. the weird thing is that when I install this in Program Files folder, the client is failing to read the config in [application].dll.config and raising an error like below:

"Could not find default endpoint element the references contract [..] in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."

I have read this article and it seems that it doesn't solve my problem. Could not find default endpoint element

Im using windows7 btw and haven't tested to other OS.

Update: After reading the above link, I've tried to move the configuration to machine.config and it works, but how do I make my application read the application config instead of machine.config?

Edwinedwina answered 26/11, 2011 at 5:57 Comment(0)
O
13

If you are using VSTO 4 SP1, then you may be running into a problem described in this blog: http://msdnrss.thecoderblogs.com/2011/06/vsto-4-0-sp1-will-cause-a-vsto-addin-to-not-find-its-config-file/ The solution is to change your registry values for your office addin from:

Manifest=”C:\Program Files\<Path>\WordAddIn.vsto|vstolocal”  

to:

Manifest=”file:///C:\Program Files\<Path>\WordAddIn.vsto|vstolocal“ 
Operose answered 27/11, 2011 at 16:0 Comment(2)
Wow! Worked for me, too! This took me hours ... uffBevins
This also resolved "Could not load file or assembly System.Memory...or one of its dependencies. The located assembly's manifest definition does not match the assembly reference" for me. Serilog SelfLog (which incorporates fuslogvw.exe) revealed that when installing a Word add-in to MS 365 on Win 11 (all three 64-bit) the machine.config was accessed instead of WordAddIn.vsto|vstolocal. Adding file:/// to the add-in's Manifest value allowed the add-in to find and load the correct dlls. Thank you @GTG!Molini
F
0

The machine .config file specifies the settings that are global to a particular machine - so whatever you changed can potentially affect every other app on the machine.

The App config contains application specific settings so your applications settings really should be in there.

When you built and deployed your application to Program Files was the app config copied along with it? Did you set the "Copy to Output Directory" property?

Farnesol answered 26/11, 2011 at 10:9 Comment(0)
D
0

If your library.dll is called from application app.exe you will need to have app.exe.config, not library.dll.config.

Dupaix answered 26/11, 2011 at 10:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.