Locking files when building in Visual Studio 2010

前端 未结 11 1903
粉色の甜心
粉色の甜心 2021-02-19 02:28

Hello there, Stackoverflow.

Recently, when I\'ve been programming in Visual Studio 2010, I\'ve been getting the problem with VS locking the bin/Debug/(Pr

11条回答
  •  别跟我提以往
    2021-02-19 03:29

    I've run into this problem a few times myself.

    Mine might not be from the same cause as yours, but I'll tell you what went wrong with me and how I fixed it, hopefully it'll be helpful to you.

    Basically, my program never fully exited properly, even when it appeared to. It would continue to run, and thus continue to lock down the file.

    A quick dirty fix I used initially (and a way to prove if this is the case) is:

    • Open Task Manager (Ctrl-Alt-Del)
    • Click Processes tab
    • Look for your program's name (TileEngine.exe)
    • Note: There will probably be name_vshost.exe (TileEngine_vshost.exe) That's a VisualStudio thing, ignore that, it's not relevant.
    • If you find it, it means your program hasn't actual exited fully.
    • If it's there, click on it and press "End Process"

    So if it's there, then for some reason, your program didn't shut down, like mine did.

    Often, this is from a thread being launched and forgotten, or an Async task that never completes, or something like that.

    Make sure in your OnExiting(..) void function that you kill all running threads.

    If your program is still running despite best attempts to close all threads and other blockers, you can use the very dirty bad method: In OnExiting(...) run the code "System.Diagnostics.Process.GetCurrentProcess().Kill();" - this will taskmanager-style forceshutdown the current process... this is only as an emergency I-can't-make-it-work-any-other-way method.

提交回复
热议问题