App.Config Files

By default, the application configuration file of the default appdomain (and other appdomains for v1.1 and later) is in the process exe’s directory and named the same as the process exe + ".config". This is true even if that exe is unmanaged. Also, note that a web.config file is an app.config - ASP.NET sets that as the config file for your appdomain.

To change the config file, set an AppDomainSetup.ConfigurationFile to the new location and pass that AppDomainSetup to your call to AppDomain.CreateDomain(). Then, run all of the code requiring that application config from within that new appdomain.

Note, though, that you won’t be able to choose the CLR version by setting the ConfigurationFile – at that point, a CLR will already be running, and there can only be one per process.

Application configuration files are per-appdomain. So, you can set a ‘dll config’ by using the method above, but that means that it will be used for the entire appdomain, and it only gets one.

Check here for info about the contents of configuration files or here for common examples.

Comments (37)
  1. Fernando Tubio says:


    Apparently, the contents of a configuration file are cached, so that any changes made to the file are not available until you unload the domain. Is there any mechanism to force the domain to reload the configuration?

  2. Suzanne says:

    Not for AppDomain configuration purposes, at least. You’d have to create a new AppDomain for it to be reloaded. That’s best for the loader’s purposes, anyway.

  3. If config files are per-appdomain; does this then mean that placing a web.config file in a web site sub-directory to do something such as alternative permissions for said folder; cause the runtime to provision a new app domain for each of the folders. If so is this done for all sub folders period or for just those with a separate web.config?

  4. Suzanne says:

    The CLR wouldn’t automatically create a new AppDomain; it would be up to the host to create it (ASP.NET). I believe that ASP.NET creates a new AppDomain per ‘app’ and uses a web.config if it’s there in the app root – I don’t think it creates AppDomains based on the location of web.configs.

  5. suzanne i want to ask you a question about the GAC but how can i do that, there is nowhere a link to a email adres.

    the question :
    I made my own dll and put it in the GAC
    the DLL contains a class called : Task
    this is the source i use :

    <%@ Import Namespace="Mpp.Wsis.Mod_sys.Task" %>
    <script language="VB" runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
    ‘author = "mve,0206032108"
    dim task1 as Mpp.Wsis.Mod_sys.Task = new Mpp.Wsis.Mod_sys.Task(2)
    end sub

    the error a get is :
    BC30002: Type ‘Mpp.Wsis.Mod_sys.Task’ is not defined.

    can you help me, or do you know someone how can?
    there is so less about real asp.dotnet on internet
    when i put a assembly tag in my page and place the dll in de bin dir it works, but don’t use the GAC
    and a want to use the GAC
    i hope to hear from you.
    i think you know a lot, when i read your info

  6. Suzanne says:

    Yes, no email because I work on developing the product, not really technical support. You can use Microsoft’s official tech support channels, though, or the MS newsgroups can also help. Assemblies retrieved from the GAC require a full assembly display name for the reference (see my blog entry at ). Check the <add assembly> tags in your machine.config file. If it doesn’t have an entry for it, add the appropriate one(<add assembly=”*” /> works for bin assemblies, but not GAC ones).

  7. michael van Engelenburg says:

    thank you for your support.
    Off Course i’ll checked the support pages first, but after 3 hour, microsoft is no longer a friend 🙂
    solution helped!!.
    Other question i can not find in the support shit.
    I made a dll placed it in the gac and want to run, but because the gac is outside the iis enviroment, i can not use a response.write() command in the dll, is there a solution , or is it possible to add an other namespace to make it possible

    thanks in advanced

  8. Suzanne says:

    Did you add the appropriate <add assembly> tag to the machine.config for the CLR loaded in the process? It sounds like it wasn’t added. If yes, check the Fusion log ( ) to see if there was some other loading problem.

  9. GG says:

    I have a Web Service with web.config, can I treat that as my App.config

  10. says:

    I create a new project and am unable to find the app.config file in the solution tree? Any pointers?



  11. Suzanne says:

    GG: Yes, ASP.NET automatically sets the app’s web.config as that appdomain’s app.config.

    woodm: VS doesn’t automatically create an app.config for you today.

  12. Benjamin C. J. Casha says:

    I have a .NET DLL I need to access from an asp app. So I have wrapperd my DLL for COM interop how ever I can’t get it to take a config file.

    Could you paste a quick example of how you would repoint an application/dll at a new config file.

  13. Suzanne says:

    Benjamin, please read the original blog entry – it answers this exact question, with the methods to call.

  14. says:

    pls tell about config file

  15. seb says:

    Hello I would like use a file: app.config for define a new attribut for my dll.

    my app.config is used for taking another class for compressed the data beetween the client and the issuer.

    When I compile it, the config file isn’t use.

    how do that??



  16. Michele Nelson says:

    <!– Web.Config Configuration File –>



    <customErrors mode="Off"/>



  17. KrisK says:

    We are having a problem where a no-touch depolyment windows form isn’t loading its app.config file. It works in all cases, except when the client has IE configured to use a proxy server. We get no errors, just the application settings collection is empty (which means our dynamic webservices fail and the application is non-functional). Any clue on this odd problem?

  18. EJ says:

    Is there a way to specify a substitution variable that can be used in several places in the app.config file (like you can do in Ant/NAnt build files)? For example, if there is part of a file path that I specify in several of the appSettings key values, can I somehow specify that path once, and just insert a substitution variable of some sort (e.g., "${path}") and have it get substituted at run-time? I could just separate them into different keys and handle it in code, but this path is being set on a key in a custom configuration section for a third-party component (log4net), so this is not possible. Also, I tried to do this using XML Entities to no avail. Please advise.

  19. sandy says:

    i can not add applicaion configurtion file in my windows application,it is not visible in add items.

  20. Juliano says:

    Hi Suzanne,

    I’m a newbie developer in .net and I’m having a little trouble to set the culture info into the app.config file.

    I find out here (

    that what I thought would be the solution, but unfortunatelly, don’t was.

    I think that <system.web> tag works just in web app, and not in desktop app, am I right ???

    There is a way to set culture info in the app.config file ? Which tag I shall to use.

    Best Regards,


  21. Beefarino says:

    Hi Suzanne;

    As long as we’re on the topic of setting up configuration via an AppDomainSetup object, do you have any insight into using the SetConfigurationBytes method?  I’m trying to use this method to supply app domain configuration from a custom host, but am having no success.  The configuration data I supply isn’t accessed by the Configuration subsystem (e.g., application settings are not available), even though I can see my configuration from the new app domain when I call AppDomainSetup.GetConfigurationBytes.  



  22. Vineesh Degapudi says:


    I rewrite the appsettings section of app.config file on application load. How do I reload (re-cache) the app.config file with .NET 1.1. I know that .Net 2.0 provides the API to do it. Is there a work around with .NET 1.1.

  23. Brett says:

    Thank you for this blog!  It is a big help.  What happens to a dll’s config file when it gets put in the GAC?  Is the configurations at the time of the GAC install retained?

    Thank you, Brett

  24. Ed says:

    If you are using .NET 2.0 settings class, it sets some default values that are compiled with the dll, so when the dll is in the GAC, it can’t find the config file and use the defaults (I guess).

    Is there any way to specify the config file to use for a shared assembly in GAC? How?

  25. Shash says:


    I have created an App.config file for my Workflow.When builded it gives me a file name as Workflow.dll.config.

    I need to add this App.config in the GAC so that when the Workflow DLL is in GAC it looks at the appropriate App.config in GAC too.

    Problem is that App.config is not getting added to the GAC.

    any solutions?



  26. Kamran Shehzad says:


    I got an issue. I am using .net dll’s (as com interop) in asp pages. app.config file works but when I add enterprise libaray logging feature in it, it stops working.

    I know how to get it works in desktop environment (by rename app.config to program.exe.config) but for website i dont know how it should be renamed or how it will work with enterprise libaray.

    Any help?

    email me at

    thank you.

  27. Dan says:


    I am a newbie in c# development and I have a problem with app.config files in debug time. My app.config file works right in runtime but not in debug time. Can they be used in debug time ?

    My app.config file is :

    <?xml version ="1.0"?>



                          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

                                      <probing privatePath="SharedLibs"/>






    Thanks in advance.

  28. Rajesh says:

    Asp.Net supports hierarchial config sections. Certain sections can be shared among diff app.config.  Is something like this available for Winforms app.config

  29. David says:

    Hi, do you know if there is an equivalent of the <add reference> section in the web.config for the app.config

  30. John says:

    Creating a new AppDomain with ASP.NET within IIS web site. New AppDomain doesn’t seem to obey the Web.Config chaining (local, wwwroot, machine.config). Is there a way to specify more than one config file this way? PS.Thanks for this site. Its a world of help.

  31. Martyn says:


    I have written a workflow custom tracking service which takes a DB Connection string in its constructor

    [Public Sub New(ByVal DBConnStr As String)].

    Everything works absolutely fine when I add this service to the workflow runtime programmatically.

    Final hurdle is to define the service in the app.config file so that the workflowruntime picks it up from there.

    So far I have got this…




    type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"



    <HostingWorkflowRuntime Name="Hosting">



     <add type="MyTrackingService.MyTrackingService, MyTrackingService, Version=, Culture=neutral, PublicKeyToken=null" DBConnStr="Data Source=Fred; Initial Catalog=Wilma; UID=Barney;PWD=Rubble; Pooling=True;" />



    The runtime picks up the service, but insists on calling its parameterless constructor, rather than the one with the string parameter. I have tried removing the parameterless constructor, but this just generates a runtime error.

    Do I need to decorate the constructor with the parameter with a particular attribute to make the runtime recognise it or what?? This is really annoying!



  32. Martyn says:

    No worries, found it myself! Oh don’t you love Microsoft documentation? As long as you know EXACTLY how to find it, all the info is there!

    Essentially, the custom tracking service has to have a constructor with a special signature for it to be definable from the app.config. When the WorkflowRuntime is created with the section name as a parameter it searches for the special signature and, if it isn’t found, always tries the parameterless constructor. Obvious really.

    See for an explanation

  33. Jeff Reddy says:

    Could you decipher this:

    To change the config file, set an AppDomainSetup.ConfigurationFile to the new location and pass that AppDomainSetup to your call to AppDomain.CreateDomain(). Then, run all of the code requiring that application config from within that new appdomain.

    What is this? AppDomainSetup.ConfigurationFile

    Where is it found?

    Where is my call to AppDomain.CreateDomain? I’ve never called that before.

    I’ve got a windows service and another windows application that both use a shared DLL. The DLL expects a config file from the hosting application.  Currently I have two config files, both identical in all but file name. I think your solution here is saying they can use the same one, but I can’t make heads or tails out of most of what you have written.  You you please break it down for the dumber guys like me?

Comments are closed.

Skip to main content