Serious problems with ConfigurationSettings class in a web service

Discussion in 'ASP .Net Web Services' started by Brad Wood, Dec 13, 2005.

  1. Brad Wood

    Brad Wood Guest

    I have a 1.1 web service that creates multiple threads and makes an http
    call within each thread. When many threads are created, the service
    fails every on other call with one of these 2 errors:

    (1) Parser Error Message: </b>The XML file
    c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config could
    not be loaded. Attempted to access an unloaded AppDomain.
    (2) Parser Error Message: </b>The XML file
    c:\windows\microsoft.net\framework\v1.1.4322\Config\machine.config could
    not be loaded. [Resource lookup failed - infinite recursion detected.
    Resource name: Arg_AppDomainUnloadedException]

    When I comment out my http call block, e.g.,
    using(HttpWebResponse response = http.GetResponse() as HttpWebResponse)
    {
    ...
    }
    The service does not fail (as I would expect).

    However, when I leave the http call in and comment out three earlier
    lines that access config constants, e.g.,
    string s = ConfigurationSettings.AppSettings.Get(1);
    The service does not fail either.

    What's even crazier is that the service takes 10X longer with the calls
    to ConfigurationSettings.AppSettings (I suppose because there is some
    conflict between the threads). The NameValueCollection base class
    underlying the AppSettings collection says that static members of this
    type are thread-safe (which AppSettings is).

    Why is the ConfigurationSettings class seeming to be so hosed up here?
    Brad Wood, Dec 13, 2005
    #1
    1. Advertising

  2. Brad Wood

    Emul Guest

    I've had similar problems in the past, so I always load the
    ConfigurationSettings one-time only, and this seems to fix the problem.
    I did not respond right away because I, too, was waiting for a
    moderator/VIP to answer. But until and unless that happens, try
    this...
    // these must be static...
    static bool GotSettings = false;
    static string SomeSetting;
    // your regular ctor loads those statics...
    MyClass() // ctor
    {
    ...
    if(!GotSettings)
    {
    SomeSetting = ConfigurationSettings.AppSettings.Get(...);
    GotSettings = true;
    }
    }
    Emul, Dec 19, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bassel Tabbara [MSFT]

    RE: ConfigurationSettings.AppSettings Error

    Bassel Tabbara [MSFT], Jul 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    697
    Bassel Tabbara [MSFT]
    Jul 7, 2003
  2. Rob Mayo
    Replies:
    6
    Views:
    438
    TJoker .NET [MVP]
    Sep 22, 2003
  3. Guest
    Replies:
    3
    Views:
    3,716
    =?Utf-8?B?TG9yaSBNY0RvbmFsZA==?=
    Feb 23, 2004
  4. Random
    Replies:
    3
    Views:
    4,537
    Matt Berther
    Dec 31, 2004
  5. Andrew Fisher
    Replies:
    3
    Views:
    446
    Andrew Fisher
    Jan 28, 2005
Loading...

Share This Page