Perhaps I solved this problem. Was the .rc file created manually, or automatically when adding a resource? If the latter, then Visual studio generates the resource.h file. In this file you need to comment out the line
#define IDI_ICON1 101
then everything works.