Microsoft KB Archive/832186

= 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 =

Article ID: 832186

Article Last Modified on 12/29/2005

-

APPLIES TO


 * Microsoft Visual C++ 2005 Express Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ .NET 2002 Standard Edition

-





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  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  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  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  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.

Note 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  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,  is a placeholder for the name of the read-only resource file that you are trying to save.

<div class="status_section">

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

<div class="moreinformation_section">

Steps to reproduce the behavior
<ol> Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.</li> The Save  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: <ol style="list-style-type: lower-alpha;"> On the Tools menu, click Options.</li> In the Options dialog box, click Show Start Page in the At startup list, and then click OK.</li> Quit, and then re-start Visual Studio .NET or Visual Studio 2005 to make sure that the Start Page appears at startup.</li></ol> </li> 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.</li> Press CTRL+SHIFT+E to make sure that Resource View is visible.</li> In Resource View, double-click any resource to open that resource in Design mode.</li> Make some changes to the resource file.</li> Use one of the methods in the &quot;Symptoms&quot; section to save the resource file.</li></ol>

Keywords: kbbug kbwindowsforms kbide kbresource kbdlg KB832186

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.