Trip Ives
Trip Ives

Reputation: 71

mySolutionName.exe file deleted from /debug directory. How to restore or rebuild?

I'm new to c#. Antivirus deleted the mySolutionName.exe file out of the /debug directory and now I cannot execute my code. I'm concerned that anything I do may make the issue worse.

When I press F5 I get an error of:

CS2012 C# Cannot open for writing --> C:\Users\me\source\repos\MyApp\MyApp\obj\Debug\MyApp.exe''

Can someone please tell me how to rebuild the file so that I can continue developing?

Upvotes: 2

Views: 738

Answers (2)

Thomas Weller
Thomas Weller

Reputation: 59459

A good way to solve this issue is looking which process currently accesses the file.

A tool to do that is Microsoft SysInternals Process Explorer. It has a feature called "Find handle or DLL ..." which can be accessed by Ctrl+F.

The result will show the process which accesses the file. You can then judge whether it's Antivirus or something else that prevents you from writing to the file. If possible, you can then take an action in that program to release the file.

Example: a program is accessing my powerpoint presentation, which has the term "Schulungen" in its file name.

Screenshot

Process Explorer figures out: it's open in Powerpoint.exe, so I can simply close the file in Powerpoint - problem fixed.

Upvotes: 2

Denis Schaf
Denis Schaf

Reputation: 2759

after your edit:

Your program is probably still running outside of the debugger. You need to use the task-manageer to kill all instances of MyApp.exe if this doesnt solve your issue a reboot should do the trick as well

So why is this happening? Most liky your application is somewhere stuck on a blocking function or in a never ending loop. maybe there is even a seperate thread still operating that you forgot to close. We lack some information to tell yout that for sure. But to find out what is happening you can close your window while running in debugger mode and see if the application properly closes. if it doesnt you can hit pause and see where the program is stuck and resolve this issue by ending the task/loop/whatever in your OnClosing function of your window.

Upvotes: 2

Related Questions