Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 789
Red Avatar asked Nov 26 '11 05:11

Red


People also ask

How do you read in configuration settings from the application config file?

Add the App. config file to your project. After creating a . NET Framework project, right-click on your project in Solution Explorer and choose Add > New Item. Choose the Application Configuration File item and then select Add.

What is the difference between web config and machine config file?

config ? The web. config files specify configuration settings for a particular web application, and are located in the application's root directory; the machine. config file specifies configuration settings for all of the websites on the web server, and is located in $WINDOWSDIR$\Microsoft.Net\Framework\Version\Config.

What is difference between app config and web config?

You can have a web. config for each folder under your web application. app. config is used for windows applications.

What is the name of the default application configuration file?

By default, the name of the configuration file is App. config. To create the output configuration file that's deployed with the app, Visual Studio copies the source configuration file to the directory where the compiled assembly is placed. This file is named <yourappname>.exe.


1 Answers

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“ 
like image 130
GTG Avatar answered Jan 04 '23 10:01

GTG