ConfigurationSection for NameValueSectionHandler
-
Friday, September 16, 2011 6:02 AMI have a custom section using NameValueSectionHandler, in a config file (called AddinApp.config).Programatically, I want a get a value of key ImpersonationWcfServices.Password.var localdllPath = @"C:\Addins\AddinTest\MyApp.Addin.config";Configuration addInConfig = ConfigurationManager.OpenExeConfiguration(localdllPath);ConfigurationSection section = config.GetSection("ImpersonationSettings");How can I get the value ??<configSections><section name="ImpersonationSettings" type="System.Configuration.NameValueSectionHandler" /></configSections><ImpersonationSettings><add key="ImpersonationWcfServices.Password" value="xxx" /></ImpersonationSettings>thanks in advanced
Should "Hi", "Thanks" and taglines and salutations be removed from posts? http://meta.stackoverflow.com/questions/2950/should-hi-thanks-and-taglines-and-salutations-be-removed-from-posts
All Replies
-
Friday, September 16, 2011 9:06 AM
-
Friday, September 16, 2011 9:22 AM
Not is possible
var section1 = config.GetSection("ImpersonationSettings") as System.Collections.Specialized.NameValueCollection;
//Error
GetSection returns ConfigurationSection type, and NameValueCollection is not ConfigurationSection
This it compiles...but how I get the value ??
ConfigurationSection section = config.GetSection("ImpersonationSettings");
Should "Hi", "Thanks" and taglines and salutations be removed from posts? http://meta.stackoverflow.com/questions/2950/should-hi-thanks-and-taglines-and-salutations-be-removed-from-posts -
Friday, September 16, 2011 9:42 AM
Sorry about that.
NameValueSectionHandler is a .NET 1.1 concept and it doesn't seem to be supported by the new model.
Try this:
You can only use it from inside the application and cannot explicitly open the configuration file.NameValueCollection section = System.Configuration.ConfigurationManager.GetSection("ImpersonationSettings") as NameValueCollection; string impersonationWcfServicesPassword = section["ImpersonationWcfServices.Password"];
Paulo Morgado -
Friday, September 16, 2011 10:04 AMI cannot, I use Addin VS and I need explicitly open the configuration file.
Should "Hi", "Thanks" and taglines and salutations be removed from posts? http://meta.stackoverflow.com/questions/2950/should-hi-thanks-and-taglines-and-salutations-be-removed-from-posts -
Saturday, September 17, 2011 5:06 PM
-
Wednesday, September 21, 2011 9:23 AMI need custom section. Thanks anyway.
Should "Hi", "Thanks" and taglines and salutations be removed from posts? http://meta.stackoverflow.com/questions/2950/should-hi-thanks-and-taglines-and-salutations-be-removed-from-posts -
Wednesday, September 21, 2011 11:08 AM



