BUG: Changes are lost when you try to save a read-only resource file (*.rc) in Visual C++ 2005, in Visual C++ .NET 2003, or in Visual C++ .NET 2002 (832186)



The information in this article applies to:

  • Microsoft Visual C++ 2005 Express Edition
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

Note Microsoft Visual C++ 2005 supports both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model.

Note Microsoft Visual C++ .NET 2002 and Microsoft Visual C++ .NET 2003 support both the managed code model that is provided by the Microsoft .NET Framework and the unmanaged native Microsoft Windows code model. The information in this article applies only to unmanaged Visual C++ code.

SYMPTOMS

When you try to save a read-only resource file (*.rc) after you make changes to the resource file, you may not be able to save the changes that you made and the changes are lost.

The symptoms depend on the version of Microsoft Visual Studio .NET or Microsoft Visual Studio 2005 that you have installed, and depend on how you try to save the resource file. After you make changes to the resource file, you use one of the following methods to save the file:

Microsoft Visual C++ .NET 2002

Note The Save Resource File Name As option is enabled only when you switch to non-code tabs in the editor such as the Object Browser tab or the Start Page tab.
  • Method 1: When you click Save Resource File Name As on the File menu, you receive the Save File As dialog box. When you try to save the file by giving the file another name, you receive a Save of Read-Only File dialog box with a four button palette. When you click Save As on the button palette, you receive the following error message:
    The file is Write-protected.
    If Source controlled check it out or use SaveAs to save to a different file.
  • Method 2: When you click the Save button on the toolbar, you receive a Save of Read-Only File dialog box with a four button palette. If you click Save As on the button palette, you receive the Save File As dialog box. If you try to save the file by giving the file a different name, you receive the Save of Read-Only File dialog box again. If you click Save As on the button palette, you receive a dialog box that says the file is write-protected.
In both these cases, you cannot save the resource file with another name.

Microsoft Visual C++ .NET 2003

Note The Save Resource File Name As option is enabled only when you switch to non-code tabs in the editor such as the Object Browser tab or the Start Page tab.
  • Method 1: When you click Save Resource File Name As on the File menu, you receive the Save of Read-Only File dialog box with a four button palette. If you click Save As or Cancel on the button palette, or you close the dialog by box clicking the Close button, you receive the following error message:
    Microsoft Development Environment has encountered a problem and needs to close. We are sorry for the inconvenience.
    When you click Don't Send, Microsoft Visual Studio .NET exits.
  • Method 2: When you click the Save button on the toolbar, you receive the Save of Read-Only File dialog box with a four button palette. When you click Save As on the button palette, an Item(s) Saved message appears on the status bar of Visual Studio .NET. If you click Close Solution on the File menu, you receive a dialog box that prompts you to save the changes that you made in different files. If you click Yes, you receive the Save of Read-Only File dialog box again. If you click Save As again, your project closes. If you open the project again, you do not see the changes that you made to the resource file.
In both these cases you cannot save the changes that you made to the resource file.

NoteResource File Name is a placeholder for the name of the read-only resource file that you are trying to save.

WORKAROUND

To work around this bug, use one of the following methods:

Method 1

Manually remove the Read-Only flag on the resource file, and then try to save the resource file from the IDE.

Method 2

Overwrite the original read-only resource file by clicking Overwrite in the Save of Read-Only File dialog box. To do this, do one of the following:
  • On the toolbar, click Save, and then click Overwrite in the Save of Read-Only File dialog box.
  • On the File menu, click Save Resource File Name As, and then click Overwrite in the Save of Read-Only File dialog box.
When you click Overwrite, the read-only flag of the resource file is removed.

Note Method 2 overwrites your original resource file.

Note In these workarounds, Resource File Name is a placeholder for the name of the read-only resource file that you are trying to save.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. The Save Resource File Name As option is enabled only when you switch to non-code tabs in the editor such as the Object Browser tab or the Start Page tab. To see the Start Page, follow these steps:
    1. On the Tools menu, click Options.
    2. In the Options dialog box, click Show Start Page in the At startup list, and then click OK.
    3. Quit, and then re-start Visual Studio .NET or Visual Studio 2005 to make sure that the Start Page appears at startup.
  3. Open an MFC Application project that contains a read-only resource file. In an existing project, you can change a resource file to read-only in Windows Explorer.
  4. Press CTRL+SHIFT+E to make sure that Resource View is visible.
  5. In Resource View, double-click any resource to open that resource in Design mode.
  6. Make some changes to the resource file.
  7. Use one of the methods in the "Symptoms" section to save the resource file.

Modification Type:MajorLast Reviewed:12/29/2005
Keywords:kbDlg kbWindowsForms kbResource kbide kbbug KB832186 kbAudDeveloper