Application configuration file is deleted when you build the solution (822752)



The information in this article applies to:

  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual C# 2005, Express Edition
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual J# 2005 Express Edition
  • Microsoft Visual J# .NET (2003)

SYMPTOMS

When you build a solution (for example, a console application, a Microsoft Windows application, or a Microsoft Windows service) in Microsoft Visual Studio .NET 2003 or in Microsoft Visual Studio 2005, the application configuration file in the output folder is deleted.

CAUSE

This behavior may occur if you manually add the ApplicationName.exe.config file to the output folder or if you use Solution Explorer to add the ApplicationName.exe.config file to the output folder.

Note ApplicationName is a placeholder for the name of the application.

RESOLUTION

To avoid this behavior, add an application configuration file to your project, and then copy the contents of original configuration file to the new application configuration file. Follow these steps to add an application configuration file to the project:
  1. On Project menu, click Add New Item.
  2. In the Add New Item dialog box, under Templates, click Application configuration file. Make sure that the file name is App.config, and then click Open.
  3. Copy the contents of the original application configuration file to the new application configuration file.
  4. On Build menu, click Rebuild Solution.
  5. Verify the existence of the configuration file in the \Bin\Debug folder, and then verify the contents of the \Bin\Debug folder. If you build the solution in Release mode, check the contents of the configuration file in the \Bin\Release folder.
Note If you change the default name of the application configuration file to something different from App.config, the new name is added to your source files, and then the build system does not generate the output configuration file.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Visual Studio .NET or Visual Studio 2005.
  2. On the File menu, click New, and then click Project.
  3. Under Project Types, click Visual C# Projects, and then under Templates, click Console Application.

    Note In Visual Studio 2005, click Visual C# under Project Types.
  4. In the Name box, name the project ConApp. Click OK.
  5. On the Build menu, click Build Solution.
  6. Create a configuration file or a simple text file in the Application folder\Bin\Debug folder, and then rename the file ConApp.exe.config. If you build the solution in Release mode, create a configuration file in the Application folder\Bin\Release folder.
  7. On the Build menu, click Rebuild Solution.
  8. Verify the existence of the ConApp.exe.config file in the Application folder\Bin\Debug folder. You notice that the file may not be in the folder. If you build the solution in Release mode, verify the existence of the ConApp.exe.config file in the Application folder\Bin\Release folder.

Modification Type:MinorLast Reviewed:10/3/2006
Keywords:kbvs2005swept kbvs2005applies kbprb kbConfig kbIDEProject KB822752 kbAudDeveloper