Microsoft KB Archive/311408

= FIX: 'Read-Only' Warning When Adding an MFC Class From a Type Library =

Article ID: 311408

Article Last Modified on 6/25/2003

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q311408



SYMPTOMS
When you add a COM wrapper class to a Microsoft Foundation Classes (MFC) project by using a type library with the Microsoft Visual Studio .NET Wizard, you may receive an error message if you browse to the type library file instead of using the library that is already registered in the registry. If the type library file has been marked Read-Only on disk and you browse to that type library by using the wizard, you receive the following error message, and adding the class fails:

Cannot save the file. The file exists and is marked Read-Only. Save the file with another file name or to another location.



RESOLUTION
To work around this problem, do any of the following:  Type the location of the type library that you want to use directly into the Location text box, rather than browsing to the file. The problem is with the code that uses the dialog box for the Browse operation, and not the actual import. -or-

 Make sure that the type library from which you need to add classes is already registered, and then add the class from the registry instead of from a file. To do this, follow these steps:  On the Project menu, select Add Class. Select MFC Class from Typelib from the list of templates. For Add Class from, select Registry. In the list of available type libraries, find the friendly name for the type library from which you want to add classes. From the list of interfaces in that type library, select the classes for which you want to add wrappers.</li> Click Finish.</li></ol>

-or-

</li> Change the file permissions for the type library so that the file is not marked Read-Only. The Add Class From TypeLib Wizard does not actually change the type library. This workaround may be useful in cases in which it is not feasible to register the type library. Note, however, that modifying file permissions can leave the type library open to accidental changes, and should be done carefully.</li></ul>

<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. This bug was corrected in Microsoft Visual C++ .NET (2003).

<div class="moreinformation_section">

Steps to Reproduce Behavior

 * 1) On the Project menu, select Add Class.
 * 2) Select MFC Class from Typelib from the list of templates.
 * 3) For Add Class from, select File.
 * 4) Click the Browse button next to the Location text box and browse to the location of a type library file that is marked as read-only.
 * 5) Click Save.

Additional query words: Excel.exe

Keywords: kbbug kbfix kbautomation kbpending KB311408

-

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

© Microsoft Corporation. All rights reserved.