config file for Class Library?

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

    #1

    config file for Class Library?

    Say, you have a C# project called "MyClassLib ". So the project would
    generate MyClassLib.dll. I want MyClassLib.dll to get some setting
    information, so I thought of creating MyClassLib.dll. config. This obviously
    doesn't work cuz it doesn't seem to be supported. Alternative solution would
    be to create your own XML file and a class that reads it... What I'm
    wondering is if there is any way that's supported by .NET framework....

    TIA


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: config file for Class Library?

    Hayato,

    It is not currently supported in the framework. You can try and access
    the information in the .config file for the application (through the current
    mechanism), or you can code your own mechanism. Using XML serialization, or
    the SOAP formatter to serialize an object which has the properties you need
    to access would probably be the easiest way to do this.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Hayato Iriumi" <hiriumi@hotmai l.com> wrote in message
    news:ORTFo7TrDH A.512@tk2msftng p13.phx.gbl...[color=blue]
    > Say, you have a C# project called "MyClassLib ". So the project would
    > generate MyClassLib.dll. I want MyClassLib.dll to get some setting
    > information, so I thought of creating MyClassLib.dll. config. This[/color]
    obviously[color=blue]
    > doesn't work cuz it doesn't seem to be supported. Alternative solution[/color]
    would[color=blue]
    > be to create your own XML file and a class that reads it... What I'm
    > wondering is if there is any way that's supported by .NET framework....
    >
    > TIA
    >
    >[/color]


    Comment

    • Madhu [MVP]

      #3
      config file for Class Library?

      Hi,

      The dll will always take configuration setting
      information of the surrogate i.e.,

      If MyClassLib.dll is used by MyProject.exe then
      MyClassLib.dll will read the configuration setting from
      MyProject.exe.c onfig.

      If you have deployed your component MyClassLib.dll in
      COM+ then it reads config settings from
      dllhost.exe.con fig since dllhost.exe is the surrogate.

      Hope this helps...

      Regards,
      Madhu

      MVP | MCSD.NET
      [color=blue]
      >-----Original Message-----
      >Say, you have a C# project called "MyClassLib ". So the[/color]
      project would[color=blue]
      >generate MyClassLib.dll. I want MyClassLib.dll to get[/color]
      some setting[color=blue]
      >information, so I thought of creating[/color]
      MyClassLib.dll. config. This obviously[color=blue]
      >doesn't work cuz it doesn't seem to be supported.[/color]
      Alternative solution would[color=blue]
      >be to create your own XML file and a class that reads[/color]
      it... What I'm[color=blue]
      >wondering is if there is any way that's supported[/color]
      by .NET framework....[color=blue]
      >
      >TIA
      >
      >
      >.
      >[/color]

      Comment

      • Hayato Iriumi

        #4
        Re: config file for Class Library?

        Hi, Madhu.
        Yeah, that's what I just found out. I was able to get the config values from
        the MyExe.exe.confi g. I guess this is because the DLL runs within
        MyExe.exe's AppDomain.

        Thanks!

        "Madhu [MVP]" <anonymous@disc ussions.microso ft.com> wrote in message
        news:01e901c3ad 43$7d05ebe0$a40 1280a@phx.gbl.. .[color=blue]
        > Hi,
        >
        > The dll will always take configuration setting
        > information of the surrogate i.e.,
        >
        > If MyClassLib.dll is used by MyProject.exe then
        > MyClassLib.dll will read the configuration setting from
        > MyProject.exe.c onfig.
        >
        > If you have deployed your component MyClassLib.dll in
        > COM+ then it reads config settings from
        > dllhost.exe.con fig since dllhost.exe is the surrogate.
        >
        > Hope this helps...
        >
        > Regards,
        > Madhu
        >
        > MVP | MCSD.NET
        >[color=green]
        > >-----Original Message-----
        > >Say, you have a C# project called "MyClassLib ". So the[/color]
        > project would[color=green]
        > >generate MyClassLib.dll. I want MyClassLib.dll to get[/color]
        > some setting[color=green]
        > >information, so I thought of creating[/color]
        > MyClassLib.dll. config. This obviously[color=green]
        > >doesn't work cuz it doesn't seem to be supported.[/color]
        > Alternative solution would[color=green]
        > >be to create your own XML file and a class that reads[/color]
        > it... What I'm[color=green]
        > >wondering is if there is any way that's supported[/color]
        > by .NET framework....[color=green]
        > >
        > >TIA
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        Working...