30

But it's a lie!

Good day to all! I have the following problem: when I try to open the resource file PriceCalculationUI.rc Visual Studio 2008 tells me that the file is opened in another editor (in vs2008 I have only 1 opened tab with .cpp file). I checked this information: run Process Explorer and searched for PriceCalculationUI handle. In results I found nothing but devenv.exe that uses PriceCalculationUI directory.

What can I do next?

Thanks for any help!

Additional information: when I rebuild (not build) the project I see dialog window with information that file PriceCalculationUI.rc was edited by another program.

TBD
  • 509
  • 7
  • 15
GrinderZ
  • 674
  • 2
  • 6
  • 16
  • Annoying bug in MsVS, that even in VS 2018 still exists. Open a RC file, do a find all for one of the dialogue items - and open the file as source. Edit and save, close the file - and often the file will be "still open" and VS declines to open it. Not sure why they can't just open it ANYWAY, and just refresh it if they detect changes like any other source file already does. Very unfortunate. – T.S Oct 08 '19 at 09:54

15 Answers15

28

I have had problems with this error (also in Visual Studio 2010) even when I don't have the .rc file / resource.h file open.

The only way to fix this for me was to manually open both files in the text editor (sometimes I get a msg box "The document '[path]\resource.h' is already open. Do you want to close it? which I answer with Yes), close both the files and try to open the resource file in the resource view.

This MS Connect page suggests closing the solution, deleting the .suo file and reopening the solution.

Edward Clements
  • 5,040
  • 2
  • 21
  • 27
21

If you encounter this issue, you will need to:

  1. close .rc, resource.h files opened inside Visual Studio and outside.
  2. collapse items in VS "Resource View" tab to give VS a chance to refresh.
  3. Try to expand .rc again from "Resource View" tab

The reason VS gives this error, I believe is that VS will automatically update these files. If you open any of these file in an editor, VS thinks there will a chance for conflict. So it gives you an error. Sometime it is a little misleading because VS appears don't know the .rc, and resource.h files are opened by itself. VS shoots itself's foot in this case.

tshepang
  • 12,111
  • 21
  • 91
  • 136
user2825261
  • 211
  • 2
  • 2
8

Problem solved: PriceCalculationUI.rc was opened in VS2008 text editor (right button click on file in solution explorer --> View code) then it was saved and closed. That's all! When I restart VS2008 problem comes back but I know what to do. May be it due to Visual Assist X? I don't know.

P.S.: Thanks for your replies: communion leads to action!

GrinderZ
  • 674
  • 2
  • 6
  • 16
  • >>but I know what to do<< -- so what was the solution that worked for you? – Edward Clements Jun 14 '13 at 12:11
  • `PriceCalculationUI.rc` was opened in VS2008 text editor (right button click on file in solution explorer --> View code) then it was saved and closed. After that `PriceCalculationUI.rc` can be opened in Resource editor. – GrinderZ Jun 14 '13 at 12:12
  • ok, thanks (my answer said "...manually open both files in the text editor...") – Edward Clements Jun 14 '13 at 12:23
  • Yes, principle is the same, thanks. But I don't understand why problem comes back after restarting Visual Studio? – GrinderZ Jun 14 '13 at 12:30
3

Close all opened files in VS. Then I am able to open rc file.

Libor B.
  • 519
  • 5
  • 9
3

This is the only way that works for me (Visual Studio 2015)
1) Open project with locked resource file
2) Close all open files of the project in Visual Studio.
3) Close Visual Studio
4) Start Visual Studio and reopen the project
5) Done. The resource file is unlocked...

2

Just open .rc file manually in visual studio

Right click on .rc file and click on Open

Yogesh Gat
  • 21
  • 2
1
  1. Close all projects in VS.
  2. Close the VS.
  3. Reopen VS with blank project.
  4. Open resource file solely.
bruce
  • 1,286
  • 11
  • 14
1

Today I encounterd the same issue and here is how I solved my problem.

Root Cause: I opened 'Resource.h' file from my solution and its currently in open state in my VS editor. When this file is open, it can't allow me to access the .rc file in resource view.("opened in another editor message is thrown)

Resolution: Simply I closed the Resource.h file in the VS editor tab then the .rc file open properly.

Hope it helps, if you have same problem.

cpp_learner
  • 362
  • 2
  • 4
  • 14
0

Here is another possibility - that you have manually edited the resource.h file, say to add a new #define, but omitted to update _APS_NEXT_CONTROL_VALUE, for example, to define a new control, I added the line

#define IDC_LIST_MAINWIN 1003

but forgot to amend the line

#define _APS_NEXT_CONTROL_VALUE 1003

to

#define _APS_NEXT_CONTROL_VALUE 1004

Once I made the change, the problem disappeared.

Ian
  • 111
  • 1
  • 2
0

It turns out that related resource include files (ex: resource1.h ) must also be closed, So...

  • make sure that the VersionResource.rc is not open
  • make sure that all related resource files are not open
  • collapse the tree in the Resource View pane
  • re-expand the tree in the Resource View pane
  • (hopefully) observe that the error is gone
CoderMark
  • 1
  • 1
0

Something not mentioned in any answer but that I encountered today:

If you have a breakpoint in the resource header file the related resource file is considered in use. Removing the breakpoint was all that was needed for everything to work again

ThE_JacO
  • 101
  • 1
0

I had this issue.

CoderMarks solution solved it for me.

Aarbona
  • 1
  • 1
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/30340273) – kian Nov 21 '21 at 07:48
0

For those who just encountered this issue, if you've tried all the above workarounds without success, just close all documents and reopen. the issue should be resolved

frankiie
  • 456
  • 1
  • 6
  • 19
0

A simple way for me (VS2022) is to right-click on a source-tab and select the "Close all but this Tab" option. Visual Studio then properly closes the file. But I also only have the problem when I edited an .rc-file... .

-1

This worked for me:

  1. close all instances of Visual Studio
  2. delete project .aps file.
  3. re-open project.

If above doesn't work, for step 2, delete all project temp vs files.

Angus Comber
  • 9,316
  • 14
  • 59
  • 107