none
<app>.exe.config vs <app>.config

    Question

  • I have a application developed in VS2008, .NET 2.0 that behaves strange when trying to load it's app.config file. On my Vista development box it correctly loads the <app>.exe.config file but the exact same setup fails on my Server 2003 test machine because it wont load any settings from the config file.

     

    If I print out AppDomain.CurrentDomain.SetupInformation.ConfigurationFile it shows that on Vista it loads PostInstallConfig.exe.Config and on Server 2003 it tries to load PostInstallConfig.config. (the application file name is postinstallconfig.exe).

     

    What would cause this behaviour and what is the recommended fix? Is it really necessary to provide two differently named config files just to be safe?

     

    Tuesday, April 01, 2008 8:56 AM

Answers

  • Yes, I am.

    After reading your post I tested without the manifest and it did indeed work correctly. Since I needed the manifest for the UAC settings I recreated the manifest and tried again and strangely enough it still works...

     

    I still don't know what the problem was, but recreating the manifest fixed the issue. Guess it, or the project, had gotten corrupted in one way or another. Many thanks for pointing me in the right direction!

     

    Tuesday, April 01, 2008 2:02 PM

All replies

  • Are you compiling a manifest file into your executable? A similar problem is described in this post.

    Tuesday, April 01, 2008 9:41 AM
  • Yes, I am.

    After reading your post I tested without the manifest and it did indeed work correctly. Since I needed the manifest for the UAC settings I recreated the manifest and tried again and strangely enough it still works...

     

    I still don't know what the problem was, but recreating the manifest fixed the issue. Guess it, or the project, had gotten corrupted in one way or another. Many thanks for pointing me in the right direction!

     

    Tuesday, April 01, 2008 2:02 PM
  • I guess the reason is that VS2008 adds an UAC manifest to you executable. See the bug
    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=290821

    My workaround is to add the assemblyIdentity node to the manifest. This gives me magically a consistent behavior under XP/2003/Vista/2008/Win7 and NET20SP1/NET20SP2.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
         <assemblyIdentity
                 name="MyCompony.myprog"
                 version="1.0.0.1234"
                 processorArchitecture="x86"
                 type="win32"
                 />

         <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
         <ms_asmv2:security>
             <ms_asmv2:requestedPrivileges>
                <ms_asmv2:requestedExecutionLevel level="asInvoker">
                </ms_asmv2:requestedExecutionLevel>
             </ms_asmv2:requestedPrivileges>
         </ms_asmv2:security>
    </ms_asmv2:trustInfo>
    </assembly>

    Thursday, June 04, 2009 7:30 AM