Error referencing key value from web.config.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • prabu.girirajan@gmail.com

    Error referencing key value from web.config.

    Hi,
    I have a web application which internally calls certain web methods of
    a web service. This web service has a interop to ATL COM Component and
    that ATL component calls a .NET assembly.
    I would like to access a key value in the .NET assembly. I added this
    to the Web.Config of the Web Service however it didnt read the value.
    I also tried adding to the Web.config of the Web application however i
    am faced with the same problem.

    Am I missing any configuration to get this working

    Cheers
    Prabu

  • Morten Wennevik

    #2
    Re: Error referencing key value from web.config.

    Hi Prabu,

    How do you configure web.config?

    If you put a key under appSettings you can read it using the
    ConfigurationMa nager.

    //web.config
    <add key="Mykey" value="MyValue" />

    //code
    string myKey = ConfigurationMa nager.AppSettin gs["MyKey"];



    On Mon, 18 Sep 2006 10:55:40 +0200, <prabu.giriraja n@gmail.comwrot e:
    Hi,
    I have a web application which internally calls certain web methods of
    a web service. This web service has a interop to ATL COM Component and
    that ATL component calls a .NET assembly.
    I would like to access a key value in the .NET assembly. I added this
    to the Web.Config of the Web Service however it didnt read the value.
    I also tried adding to the Web.config of the Web application however i
    am faced with the same problem.
    >
    Am I missing any configuration to get this working
    >
    Cheers
    Prabu
    >


    --
    Happy Coding!
    Morten Wennevik [C# MVP]

    Comment

    • prabu.girirajan@gmail.com

      #3
      Re: Error referencing key value from web.config.

      Hi Morten
      Thanks for your quick response.
      The web.config setting is

      <add key = "MaximumIterati ons" value="10" />

      and in the code
      maximumIteratio n =
      Convert.ToInt32 (System.Configu ration.Configur ationSettings.A ppSettings["MaximumIterati ons"]);


      I have got a method to return all the configuration setting. however
      this just does not return anything.
      private void GetAllAttribute s()
      {
      for( int i = 0;
      i<System.Config uration.Configu rationSettings. AppSettings.Cou nt; i++)
      {
      System.Diagnost ics.EventLog.Wr iteEntry("My
      Application",Sy stem.Configurat ion.Configurati onSettings.AppS ettings[i]);
      }
      }

      Cheers
      Prabu Girirajan

      Morten Wennevik wrote:
      Hi Prabu,
      >
      How do you configure web.config?
      >
      If you put a key under appSettings you can read it using the
      ConfigurationMa nager.
      >
      //web.config
      <add key="Mykey" value="MyValue" />
      >
      //code
      string myKey = ConfigurationMa nager.AppSettin gs["MyKey"];
      >
      >
      >
      On Mon, 18 Sep 2006 10:55:40 +0200, <prabu.giriraja n@gmail.comwrot e:
      >
      Hi,
      I have a web application which internally calls certain web methods of
      a web service. This web service has a interop to ATL COM Component and
      that ATL component calls a .NET assembly.
      I would like to access a key value in the .NET assembly. I added this
      to the Web.Config of the Web Service however it didnt read the value.
      I also tried adding to the Web.config of the Web application however i
      am faced with the same problem.

      Am I missing any configuration to get this working

      Cheers
      Prabu
      >
      >
      >
      --
      Happy Coding!
      Morten Wennevik [C# MVP]

      Comment

      • Morten Wennevik

        #4
        Re: Error referencing key value from web.config.

        Well, your code should work, although in .Net 2.0 you should use
        ConfigurationMa nager instead of ConfigurationSe ttings. Both should work..

        Could you show me your web.config?

        - Morten

        On Mon, 18 Sep 2006 11:23:49 +0200, <prabu.giriraja n@gmail.comwrot e:
        Hi Morten
        Thanks for your quick response.
        The web.config setting is
        >
        <add key = "MaximumIterati ons" value="10" />
        >
        and in the code
        maximumIteratio n =
        Convert.ToInt32 (System.Configu ration.Configur ationSettings.A ppSettings["MaximumIterati ons"]);
        >
        >
        I have got a method to return all the configuration setting. however
        this just does not return anything.
        private void GetAllAttribute s()
        {
        for( int i = 0;
        i<System.Config uration.Configu rationSettings. AppSettings.Cou nt; i++)
        {
        System.Diagnost ics.EventLog.Wr iteEntry("My
        Application",Sy stem.Configurat ion.Configurati onSettings.AppS ettings[i]);
        }
        }
        >
        Cheers
        Prabu Girirajan
        >
        Morten Wennevik wrote:
        >Hi Prabu,
        >>
        >How do you configure web.config?
        >>
        >If you put a key under appSettings you can read it using the
        >ConfigurationM anager.
        >>
        >//web.config
        ><add key="Mykey" value="MyValue" />
        >>
        >//code
        >string myKey = ConfigurationMa nager.AppSettin gs["MyKey"];
        >>
        >>
        >>
        >On Mon, 18 Sep 2006 10:55:40 +0200, <prabu.giriraja n@gmail.comwrot e:
        >>
        Hi,
        I have a web application which internally calls certain web methodsof
        a web service. This web service has a interop to ATL COM Component and
        that ATL component calls a .NET assembly.
        I would like to access a key value in the .NET assembly. I added this
        to the Web.Config of the Web Service however it didnt read the value.
        I also tried adding to the Web.config of the Web application however i
        am faced with the same problem.
        >
        Am I missing any configuration to get this working
        >
        Cheers
        Prabu
        >
        >>
        >>
        >>
        >--
        >Happy Coding!
        >Morten Wennevik [C# MVP]
        >


        --
        Happy Coding!
        Morten Wennevik [C# MVP]

        Comment

        Working...