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
  1. Home
  2. General Programming
  3. C#
  4. building a app.config file in a control (dll)

building a app.config file in a control (dll)

Scheduled Pinned Locked Moved C#
3 Posts 3 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.
  • U Offline
    U Offline
    User 2657147
    wrote on last edited by
    #1

    An exe generates a myexe.exe.cfg file by default. However, if I add a app.config to a dll it does not generate a similar file. I would like my control (derived from Label) to have it's own key/value configuration file. Thanks Phil

    P N 2 Replies Last reply
    0
    • U User 2657147

      An exe generates a myexe.exe.cfg file by default. However, if I add a app.config to a dll it does not generate a similar file. I would like my control (derived from Label) to have it's own key/value configuration file. Thanks Phil

      P Offline
      P Offline
      Pascal 0
      wrote on last edited by
      #2

      http://www.codeproject.com/dotnet/dllappconfig.asp[^]

      1 Reply Last reply
      0
      • U User 2657147

        An exe generates a myexe.exe.cfg file by default. However, if I add a app.config to a dll it does not generate a similar file. I would like my control (derived from Label) to have it's own key/value configuration file. Thanks Phil

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You may also find this article useful http://www.codeproject.com/useritems/CustomConfigurationMgr.asp?msg=1930993&mode=all&userid=16070#xx1930993xx[^] As well as my comments to it public class MyAssembly { public string GetValue() { System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(this.GetType()); ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = System.IO.Path.GetFileName(asm.CodeBase) + ".config"; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); return config.AppSettings.Settings["TestKey"].Value; } } In Windows or web app MyAssembly asm = new MyAssembly(); string value = asm.GetValue();


        only two letters away from being an asset

        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