Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Some issues about ConfigurationManager

Some issues about ConfigurationManager

Scheduled Pinned Locked Moved C#
xmlworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    andreumv
    wrote on last edited by
    #1

    I have a custom section defined in the app.config of my application and I want to read the parameters and store the values in a custom class, but I find that the code for ConfigurationManager.GetSection() returns a null value, and I can't find the reason. the full code is the following: public class WSProvidersFactory : IConfigurationSectionHandler { public object Create(object parent, object configContext, System.Xml.XmlNode section) { WSProvider objProvider = new WSProvider(); objProvider.Name = section.SelectSingleNode("Name").InnerText; objProvider.Type = section.SelectSingleNode("Type").InnerText; objProvider.Url = section.SelectSingleNode("Url").InnerText; return objProvider; } public static string GetProviderUrl(ServiceType _typeService) { WSProvider _provider = null; switch (_typeService) { case ServiceType .Local: throw new Exception("Not Implemented."); case ServiceType.MainWS: _provider = (WSProvider)System.Configuration.ConfigurationManager.GetSection ("WebServiceClientProviders/WsNetTiersProviderPrincipal"); break; case ServiceType.AltWS: _provider = (WSProvider)System.Configuration.ConfigurationManager.GetSection ("WebServiceClientProviders/WsNetTiersProviderSecundario"); break; } return _provider.Url; } [Serializable] private class WSProvider { private string _name; public string Name { get { return _name; } set { _name = value; } } private string _type; public string Type { get { return _type; } set { _type = value; } } private string _url; public string Url { get { return _url; } set { _url = value; } } } } AND the code in the app.config file is this: < < < <

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups