locked
What is the different between configuration file mechanism between assemblies built by VS2005 and VS2008. RRS feed

  • Question

  • I am working on a legacy program, for example: MyApp.exe. It was built by VS2005 and .Net 2.0. Unfortunately this program has a configuration file name MyApp.config, and this file does not follow the XML schema defined by System.Configuration.

    This program works well for our customer for many years.

    Now, we upgrade the source code to VS2008 and .Net 3.5, and rebuild the program, but it throws the following exception when connecting to database (we just call System.Data.Oledb API, we never call System.Configuration API):

    System.Configuration.ConfigurationErrorsException: Configuration file MyApp.config does not have root <configuration> tag

    I try to build the program with VS2008 and .Net 2.0, it throws the same exception also. I have to modify the program name to MyApp_.exe, it can work well. But I don't think this is reasonable to our customer.

    Please please help us get out of this, thanks a loooooot!

    BTW, I read the following post, but I cannot find anything useful...

    http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/c82d6033-f881-4714-beb7-6d363dbcd498


    • Moved by Cookie Luo Friday, March 25, 2011 5:05 AM (From:Visual C# General)
    Wednesday, March 23, 2011 9:42 AM

All replies

  • Hi

    I move this thread to CLR forum for better support.

    Thanks for your understanding.


    Cookie Luo[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 25, 2011 5:05 AM
  • Hi lifegame,

     

    Could you please show us the config file—MyApp.config?

    It is closed to the configuration, so we need more information about it to provide a better response.

     

    Have a nice day!


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 25, 2011 5:12 AM
  • Hi lifegame,

     

    I suggest that you can re-generate the app.config file by VS.

     

    Please remove the config file firstly, then follow the steps as below:

    Right click your project->Add->New Item->Application Configuration File.

    A new app.config file will generate by VS automatically that satisfy the requirement.

     

    I hope this can help resolve your problem. Have a nice day!


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Paul Zhou Thursday, March 31, 2011 5:37 AM
    • Unmarked as answer by Paul Zhou Monday, April 25, 2011 5:43 AM
    Monday, March 28, 2011 3:39 AM
  • The fact is I do not want to use the app.config generated by VS.

    I name my configuration file as the same name as the app.config, and I want to parse it myself. This works well in VS2005.
    But the stupid CLR in VS 2008 seems to parse the configuration file automatically, and throw the exception.

    My configuration file is something like:

    <MyAppConfig>
     <MySetting1>ABC</MySetting1>
     <MySetting2>EFG</MySetting2>
    </MyAppConfig>

    Monday, April 25, 2011 4:16 AM
  • The fact is I do not want to use the app.config generated by VS.

    I name my configuration file as the same name as the app.config, and I want to parse it myself. This works well in VS2005.
    But the stupid CLR or something in VS 2008 seems to parse the configuration file automatically, and throw the exception.

    My configuration file is something like:

    <MyAppConfig>
     <MySetting1>ABC</MySetting1>
     <MySetting2>EFG</MySetting2>
    </MyAppConfig>

    Monday, April 25, 2011 4:17 AM
  •  

    You can add tag <MyAppConfig>  to app.config file. According to the error message: "Configuration file MyApp.config does not have root <configuration> tag ", root tag <configuration> is necessary.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 25, 2011 4:39 AM
  • Sorry, this is not a reasonable solution for us.

    The <MyAppConfig> ... configuration file has been working well in the customer site for many years, and it contains lots of customized settings. We will not change the configuration file schema.

    Is it possible to prevent the CLR or ADO.Net from automatic reading the app.config when connecting database?

    Monday, April 25, 2011 5:25 AM
  • I saw a similar post on this site. But there is no solution either. It really disappoint me...

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/6aca67b4-291f-43bf-b6f7-e210d3b7ffd9/

    Monday, April 25, 2011 5:39 AM