Problem with app.config from dll

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bragadiru

    #1

    Problem with app.config from dll

    I have a solution with 2 projects: a class library(my.dll) + a windows
    application (mine.exe). In exe project I have a reference to the dll. In
    both I have app.config files, BUT only mine.exe.config file is generated in
    \bin\Debug\ folder of exe app. What can I do to generate my.dll.config from
    app.config, too?

    Thnx for any advice.



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Problem with app.config from dll

    Bragadiru,

    DLL (class libraries) do not have config files. Rather, they share the
    configuration information of the EXE that is being used.

    What you will have to do is create your own configuration file and read
    it appropriately.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "Bragadiru" <adrian@cims.ro > wrote in message
    news:OZv28PzZDH A.4028@tk2msftn gp13.phx.gbl...[color=blue]
    > I have a solution with 2 projects: a class library(my.dll) + a windows
    > application (mine.exe). In exe project I have a reference to the dll. In
    > both I have app.config files, BUT only mine.exe.config file is generated[/color]
    in[color=blue]
    > \bin\Debug\ folder of exe app. What can I do to generate my.dll.config[/color]
    from[color=blue]
    > app.config, too?
    >
    > Thnx for any advice.
    >
    >
    >[/color]


    Comment

    • Jay B. Harlow [MVP - Outlook]

      #3
      Re: Problem with app.config from dll

      Bragadiru,
      The .Net framework, by default does not use a my.dll.config. Any dll in your
      solution will use the mine.exe.config file.

      You can 'force' your DLL to use the my.dll.config, by creating a new
      AppDomain, setting the AppDomainSetup. ConfigurationFi le to 'my.dll.config' ,
      then run the dll in the second AppDomain. Then ensure that the dll runs in
      this second AppDomain, while your exe runs in the first AppDomain... There
      have been posts in one of the microsoft public dotnet newsgroups on how to
      get it to work, I do not have links handy.

      Currently I manually add the settings the DLL needs to my 'mine.exe.confi g'
      file and let the dll use those. I use custom configuration sections to
      ensure that DLL settings are isolated from exe settings.

      These dll configuration sections are defined via:
      http://msdn.microsoft.com/library/de...onhandlers.asp

      and:
      http://msdn.microsoft.com/library/de...ionsschema.asp

      Eventually I intend on creating a custom
      System.Configur ation.Install.I nstaller class that will add the needed
      entries to the app.config that the dll needs.

      Hope this helps
      Jay

      "Bragadiru" <adrian@cims.ro > wrote in message
      news:OZv28PzZDH A.4028@tk2msftn gp13.phx.gbl...[color=blue]
      > I have a solution with 2 projects: a class library(my.dll) + a windows
      > application (mine.exe). In exe project I have a reference to the dll. In
      > both I have app.config files, BUT only mine.exe.config file is generated[/color]
      in[color=blue]
      > \bin\Debug\ folder of exe app. What can I do to generate my.dll.config[/color]
      from[color=blue]
      > app.config, too?
      >
      > Thnx for any advice.
      >
      >
      >[/color]


      Comment

      • Bragadiru

        #4
        Re: Problem with app.config from dll

        See MSDN -> Visual Basic and Visual C# Concepts

        Walkthrough: Storing and Retrieving Dynamic Properties

        "The configuration file in the project folder is named App.config. When you
        build the project, it is copied to the output folder and renamed to
        Assemblyname.co nfig, where assemblyname is the project output, for example,
        MyLibrary.dll or MyApplication.e xe. You need to modify this copy of the
        ..config file to affect a deployed application."


        !!??????

        "Bragadiru" <adrian@cims.ro > wrote in message
        news:OZv28PzZDH A.4028@tk2msftn gp13.phx.gbl...[color=blue]
        > I have a solution with 2 projects: a class library(my.dll) + a windows
        > application (mine.exe). In exe project I have a reference to the dll. In
        > both I have app.config files, BUT only mine.exe.config file is generated[/color]
        in[color=blue]
        > \bin\Debug\ folder of exe app. What can I do to generate my.dll.config[/color]
        from[color=blue]
        > app.config, too?
        >
        > Thnx for any advice.
        >
        >
        >[/color]


        Comment

        Working...