0

I have an old MFC application that I've been updating with Visual Studio Pro 2015 (Update 3). All of a sudden, I started getting the following error.

enter image description here

The error happens anytime I try to save a resource, whether it's a dialog, ribbon or version resource.

After the error, I get a message saying it cannot save the file, and then opens a Save dialog box to offer an alternate filename/location to save myapplication.rc. If I select the same file, I get a prompt saying the filename already exists and asks me if I want to overwrite it. If I answer yes, I get the same error message as before.

I can find very little information on this. Apparently, it's having trouble saving my resource file, but why? Any tips appreciated!

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
  • At a guess, you have one or more resources that use standard MFC stuff (icons? dialogs? .rc file?). The new VS is trying to update that resource to the new version, and fails when it tries to save. Look thru your resource file(s) and see if anything is referencing a path that points into an old VS install (possibly looking at the .rc file in a text editor, not the resource editor). – 1201ProgramAlarm Dec 19 '16 at 00:26

1 Answers1

0

Turns out the problem is due to a recent change. I added code that uses CDatabase to access an old MDB file. However, I was getting an error in dbcore.cpp when it attempted to load a resource string to display an error. (MFC internal error: unable to load error string from resource.)

After researching this, I solved this issue by adding the following line to my application's RC file.

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"
#include "afxdb.rc" <------ ADDED THIS LINE HERE!!!

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

If I remove that added line, then my issue here goes away.

Unfortunately, it also means that errors in dbcore.cpp are once again unable to load error message resources. So I still have an issue. But I've posted a new question on that.

Community
  • 1
  • 1
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466