Share via


Cannot access a disposed object

Question

Monday, March 2, 2020 5:44 AM

I have a C++14 x64 application built with visual studio enterprise 2017 (v15.9.4)

I am trying to add an icon for my exe but when I try to add in a new resource file (Resources.rc) I get an exception from visual studio:

Cannot access a disposed object.
Object name:
`Microsoft.VisualStudio.Project.VisualC.VCProjectiEngine.VCProjectFileShim`.

and

The object has already been disposed. (Exception from HRESULT 0x80131622

I have created other projects and successfully added Resources.rc but for this particular project I am getting the above exceptions. Is there a way to fix the project file without having to recreate the project from scratch?

All replies (3)

Monday, March 2, 2020 6:06 AM

A file `resource.h` is generated. So it seems that it has an exception midway while building the resource file chain?


Tuesday, March 3, 2020 6:21 AM

Hi Christopher,

Welcome to MSDN forum.

>> I have created other projects and successfully added Resources.rc

## The projects you mentioned above are the same project template(C++ x64 application), am I right? If yes, I think the issue may hide in the codes or configurations, I mean maybe you call some methods which affect the resources/icons.

You could try to close other applications which may affect/occupy the program, then close all instance and restart VS to try again. Also, check if you have installed some related dlls/SDK/references/nuget packages/extensions and if possible, try to remove/re-add/disable/stop them.

In addition, you could try to go to your project folder and remove the hidden .vs folder then rebuild your project again, and try to repair VS 2017 from VS Installer => VS 2017 => More => Repair.

If you created other project templates which are different from VC++ x64... I suggest you could try to create a new simple project just as the same template as your application’s and test if this issue appears this time.

Hope this could help you.

Kind Regards,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Tuesday, March 10, 2020 7:45 AM

Hi Christopher,

Sorry to bother you.

Do you have any update? If this issue still persists, feel free to contact us.

Best Regards,

Tianyu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].