Application settings in dll.config

Respondido Application settings in dll.config

  • quarta-feira, 17 de agosto de 2011 15:36
     
     

    Is the dll.config file similar to the web.config or the exe.config files where in when we make changes to any of these config files we don't have to recompile the web or the windows app and from the next request the new settings are picked up.

    My question is will the dll.config file behave in the similar manner, I have added application settings in my class library project which is referenced in my web application.

    Thanks.

Todas as Respostas

  • quinta-feira, 18 de agosto de 2011 00:17
     
     

    On web applications I don't recall if it triggers a recycle or not but, other than that, it behaves pretty much the same.

    Are you having any problems?


    Paulo Morgado
  • quinta-feira, 18 de agosto de 2011 01:51
     
     

    If your DLL is written by yourself too and it's designed to be used by web application, I'd recommand using WebConfigurationManager instead to match the web codes view of config file in current virtual directory level.

    Btw, changing config files (not sure if it's just web.config only or *.config) WILL trigger recompilation of the web application.

  • quinta-feira, 18 de agosto de 2011 12:21
     
     

    I mean if your webservice has a web.config file and if you make any change in it you don't have to recompile the webservice application and the new settings are fetched with the next new request and it is same for the exe.config file which is used in your windows application.

    I wanted to check if I add a App.config file in my class library project which referenced by some other webapplication. Seettings in this config file are created thru the Settings.settings which is created using project properties. Now, when you build the class library project u also see the dll.config file, my question does this ddl.config similar to web.config or the exe.config where in I don't need to recompile the project.

    Here in the class library the settings are created thru the settings tab on the project property which I need to access in the class library.

    Plz do let me know. thanks.

  • quinta-feira, 18 de agosto de 2011 13:24
    Moderador
     
     Respondido

    Just to clarify dll.config is not a runtime file.  The only application-level file read by the runtime is <app>.exe.config for non-web based apps and web.config for web apps.  Any settings that any class library needs must reside in one of these 2 files otherwise it will never be seen.

    The reason dll.config exists at all is because VS doesn't distinguish between libraries and EXEs when it needs to generate config settings.  Therefore if you happen to be inside a library and VS needs to generate a config entry it'll generate it in a dll.config but that file will never be used at runtime.  You are expected to merge this file into the main config file as needed.

    Refer to MSDN and the many, many articles on this subject and why it works that way.  In summary, you must merge any dll.config file settings into your main web.config.  Having a config file in a library project (irrelevant of what you call it) will never be used.  Once merged any changes to the config will cause the web app to be recycled.

    Michael Taylor - 8/18/2011
    http://msmvps.com/blogs/p3net

     

    • Sugerido como Resposta vladislavm quinta-feira, 18 de agosto de 2011 13:59
    • Marcado como Resposta Jackie-SunModerator quarta-feira, 24 de agosto de 2011 05:27
    •  
  • sábado, 14 de abril de 2012 12:41
     
     

    This is nothing new. On hundreds of threads people are saying the same thing and we get it. There's something missing in all those answers. What about a practical example of how to merge the class library's settings into the config file of the hosting executable?

    Cheers.


    Beginner