Getting Access Violation every time I modified web.config

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

    Getting Access Violation every time I modified web.config

    Hi,

    I am getting the following exception every time I modified web.config, the
    only way to fix it is to recycle application pool or restart IIS, but I
    don't want to do that all the times. TIA

  • Mark Rae [MVP]

    #2
    Re: Getting Access Violation every time I modified web.config

    "Raymon Du" <rdrd@yahoo.com wrote in message
    news:ut9VgwfwIH A.4488@TK2MSFTN GP04.phx.gbl...
    I am getting the following exception every time I modified web.config, the
    only way to fix it is to recycle application pool or restart IIS, but I
    don't want to do that all the times. TIA
    Modifying web.config will cause an ASP.NET application to recycle... There
    are some really convoluted (and totally pointless) exceptions to this, which
    are best avoided...

    If you don't want your ASP.NET application to recycle, don't modify
    web.config... Store dynamic variables somewhere else...


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • Raymon Du

      #3
      Re: Getting Access Violation every time I modified web.config

      I don't understand your response at all. Don't modify web.config at all?
      Where do you suggest me to connection strings? Har coded in some .cs files?
      It's a common practice to store connection strings into web.config then
      change them for switching to defferent environments. But ASP.Net runtime
      throws exceptions if connection strings are changed in my case.


      "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message
      news:O5oU%232fw IHA.2208@TK2MSF TNGP04.phx.gbl. ..
      "Raymon Du" <rdrd@yahoo.com wrote in message
      news:ut9VgwfwIH A.4488@TK2MSFTN GP04.phx.gbl...
      >
      >I am getting the following exception every time I modified web.config,
      >the only way to fix it is to recycle application pool or restart IIS, but
      >I don't want to do that all the times. TIA
      >
      Modifying web.config will cause an ASP.NET application to recycle... There
      are some really convoluted (and totally pointless) exceptions to this,
      which are best avoided...
      >
      If you don't want your ASP.NET application to recycle, don't modify
      web.config... Store dynamic variables somewhere else...
      >
      >
      --
      Mark Rae
      ASP.NET MVP
      http://www.markrae.net

      Comment

      • Mark Rae [MVP]

        #4
        Re: Getting Access Violation every time I modified web.config

        "Raymon Du" <rdrd@yahoo.com wrote in message
        news:ey1ce8fwIH A.5288@TK2MSFTN GP06.phx.gbl...

        [top-posting corrected]
        >>I am getting the following exception every time I modified web.config,
        >>the only way to fix it is to recycle application pool or restart IIS,
        >>but I don't want to do that all the times. TIA
        >>
        >Modifying web.config will cause an ASP.NET application to recycle...
        >There are some really convoluted (and totally pointless) exceptions to
        >this, which are best avoided...
        >>
        >If you don't want your ASP.NET application to recycle, don't modify
        >web.config.. . Store dynamic variables somewhere else...
        >
        I don't understand your response at all.
        OK.
        Don't modify web.config at all?
        Yes, that's right. DON'T MODIFY WEB.CONFIG AT ALL!
        Where do you suggest me to [store] connection strings?
        In web.config - as many as you need.
        Hard coded in some .cs files?
        Absolutely not.
        It's a common practice to store connection strings in web.config then
        change them for switching to different environments.
        It most certainly isn't!!! Web.config is not designed for this sort of
        behaviour, as you've discovered... Web.config is designed for storing
        application-specific data and metadata WHICH NEVER CHANGES while the
        application is running.
        But ASP.Net runtime throws exceptions if connection strings are changed in
        my case.
        Yes, that's correct. Because web.config is not designed to be used in this
        way...

        Why do you need to modify your connection string(s) while your web
        application is running?


        --
        Mark Rae
        ASP.NET MVP


        Comment

        • Juan T. Llibre

          #5
          Re: Getting Access Violation every time I modified web.config

          re:
          !I don't understand your response at all. Don't modify web.config at all?

          He didn't say that at all.
          He said "If you don't want your ASP.NET application to recycle, don't modify web.config".

          If you modify web.config, your ASP.NET application *will* recycle.

          re:
          !Where do you suggest me to connection strings?
          !Har coded in some .cs files?

          No, but you could have a helper config file named connections.con fig, for example.

          <connectionStri ngs configSource="c onnections.conf ig"/>

          To enable the configuration to be recognized on any change to "connections.co nfig",
          edit machine.config, in the <configSections section, and edit <section name="connectio nStrings" ... >,
          adding : restartOnExtern alChanges="true "

          That'd make it :

          <section name="connectio nStrings" type="System.Co nfiguration.App SettingsSection , System.Configur ation,
          Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b03f5f7f11d50a3 a" restartOnExtern alChanges="true "
          requirePermissi on="false" />




          Juan T. Llibre, asp.net MVP
          asp.net faq : http://asp.net.do/faq/
          foros de asp.net, en espaƱol : http://asp.net.do/foros/
          =============== =============== ========

          "Raymon Du" <rdrd@yahoo.com wrote in message news:ey1ce8fwIH A.5288@TK2MSFTN GP06.phx.gbl...
          >I don't understand your response at all. Don't modify web.config at all? Where do you suggest me to connection
          >strings? Har coded in some .cs files? It's a common practice to store connection strings into web.config then change
          >them for switching to defferent environments. But ASP.Net runtime throws exceptions if connection strings are changed
          >in my case.
          >
          >
          "Mark Rae [MVP]" <mark@markNOSPA Mrae.netwrote in message news:O5oU%232fw IHA.2208@TK2MSF TNGP04.phx.gbl. ..
          >"Raymon Du" <rdrd@yahoo.com wrote in message news:ut9VgwfwIH A.4488@TK2MSFTN GP04.phx.gbl...
          >>
          >>I am getting the following exception every time I modified web.config, the only way to fix it is to recycle
          >>application pool or restart IIS, but I don't want to do that all the times. TIA
          >>
          >Modifying web.config will cause an ASP.NET application to recycle... There are some really convoluted (and totally
          >pointless) exceptions to this, which are best avoided...
          >>
          >If you don't want your ASP.NET application to recycle, don't modify web.config... Store dynamic variables somewhere
          >else...
          >>
          >>
          >--
          >Mark Rae
          >ASP.NET MVP
          >http://www.markrae.net
          >
          >


          Comment

          Working...