LINK: fatal error LNK1104: cannot open file 'D: \ ... \ MyProj.exe'

Using Visual Studio 2010, when I build + run my application at short intervals, I often get the following error. If I just wait a minute or two and try again, everything will be fine. Unlocker claims that the handle does not block the executable.
How can I find out what blocks it?
If this is Visual Studio itself, what should I do to stop it? or alternatively to release a file?

1>------ Build started: Project: MyProj, Configuration: Release Win32 ------ ... 1>InitializeBuildStatus: 1> Creating "Release\MyProj.unsuccessfulbuild" because "AlwaysCreate" was specified. 1>ClCompile: 1> All outputs are up-to-date. 1> SomeFile1.cpp 1>ResourceCompile: 1> All outputs are up-to-date. 1>LINK : fatal error LNK1104: cannot open file 'D:\...\MyProj.exe' 1> 1>Build FAILED. 1> 1>Time Elapsed 00:00:00.94 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 
+43
locking visual-studio visual-studio-2010 executable
Oct 11 '10 at 13:00
source share
15 answers

Was this a question after reinstalling today. Verify that the Application Experience service is running and not disabled. If you install it manually, I believe that VS will launch it.

+37
Oct 13 '11 at 6:41
source share

You probably had a random build process that blocked the executable, and it (the failed process) did not clear. In this case, close the visual studio, open the process explorer and nuke every process that you can find associated with the visual studio. Then reopen the visual studio and try rebuilding your project.

+11
Oct. 11 '10 at 13:21
source share

I know this is pretty old, but I had the same problem as in Visual Studio 2010, all fixed, so others may run into this.

Adding my path to Excluded Items in my AVG antivirus settings seems to fix the problem for me.

Try disabling any antivirus / resident screen and see if it fixes the problem. If so, add your path to the excluded directories to the AV configuration.

+8
Sep 05 2018-11-11T00:
source share

The file may be locked because it is executing now. Try to kill the process using the task manager.

+4
Oct 11 2018-10-10
source share

You may not have closed the exit. Close the exit, clean and rebuild the file. You may be able to run the file.

+4
Mar 30 '12 at 1:11
source share

As Jonathan said, yes, renaming can help get around this problem. But, for example, I was forced to rename the target executable file many times, this is a bit tedious and not very good.

The problem is that when you start the project and the subsequent error, you cannot create your project - this is because this executable file (your project) is still running (you can check it using the task manager). If you simply rename the assembly of targets, after a while you will get the same error with a new name, and if you open the task manager, you will see that you are overwriting the system with your unfinished projects.

To create a new assembly, Visual studio must delete the previous executable file and create a new one, not the old one, it will not be able to do this while the executable file is still running. So, if you want to create a new assembly, the process of the old executable file must be closed! (it is strange that the visual studio does not close it by itself and yes, it looks like an incorrect behavior).

enter image description here

It’s a little tedious to do this manually, so you can just bat file and just click on it when you have this problem:

 taskkill /f /im name_of_target_executable.exe 

it works for me at least. As a hunch, I am not closing my program properly in C ++, so it might work fine for a visual studio.

Addition: There is a great chance to be so, because of the unfinished application. Check if you finally named PostQuitMessage to let you know what you did.

+4
Nov 26
source share

I came to the conclusion that this is some kind of Visual Studio error. Perhaps Johnson is right - perhaps the build process is blocking the file.

I have a workaround that works - every time it happens - I change the target name of the executable in the project properties (right-click the project, then Properties \ Configuration Properties \ General \ Target Name).

Thus, VS creates a new executable file, and the problem is resolved. Every few times I do this, I return to the original name, thus driving through ~ 3 names.

If someone finds a reason for this and a solution, answer and I can move the answer to yours as my workaround.

+2
Dec 10 '10 at 8:16
source share

I had the same problem, but using Codeblocks. Because of this problem, I refused to program, because every time I just wanted to throw my computer out of the window.

I want to thank user963228. The answer to all this is really a solution. You have to put Application Experience in a manual launch (you can do this by searching for services in the Windows 7 start menu, and then find Application Experience and click properties).

This problem occurs when people want to configure their windows 7 machine, and they decide to disable some meaningless services, so they contain Google setup guide, and most of these tutorials say that Application Experience is safe to disable.

I think this problem should be related to the Windows 7 problem, and not to the VS problem, and it should be more noticeable - it took me a long time to find this solution.

Thanks again!

+2
Oct 26 '11 at 6:41
source share

To add another solution to the list, I found that Visual Studio (in my case in 2012) sometimes blocks files in different processes.

So, if devenv.exe fails, it can still work and hold the file (s). Alternatively (as I just opened), vstestrunner or vstestdiscovery can also be stored in a file.

Kill all of these processes and this may solve the problem.

+1
Jan 04 '14 at 0:16
source share

I just ran into the same issue with VS2013 creating device drivers in C ++, and none of the above problems solved the problem. However, I just found that in my case the problem is related to VMWare.

I worked with a VMWare workstation client with a shared folder defined in a virtual machine on my C: drive. When I disabled shared folders in the virtual machine settings, VS2013 was able to happily create my .exe files.

My new process:

1) Disable the shared folder in vm (Virtual Machine Settings | Options | Public Folders) and uncheck the box. 2) Run the assembly on the main PC 3) RE-enable the shared folder (and go from there)

Hope this can help someone else.

(BTW, you get errors that .exe (or other files) are blocked or require administrator permission, but this is a red herring. It seems to me that the VMWare share causes these files to appear as locked.)

+1
Jun 13 '14 at 17:56
source share

The error arises (at least sometimes) from too long paths. In my project, simply shortening the path of the output file does the job: "Properties / Configuration Properties / Shared / Intermediate Directory"

It seems like I hit a space limit of 250 characters.

0
Mar 07 '13 at 14:00
source share

Working with the principles and practice of programming Bjarne Stroustrup using the "FLTK" example in C ++, I got the same error, but after I got an idea in 1 hour, I was tracking one of the libraries that were already visible in Project Properties β†’ Linker β†’ Input β†’ Additional dependencies, in my case I tracked kernel32.lib to see where it was and saw that there were a lot of kernel32.lib in different folders. So I started copying the FLTK libraries in these folders and the last one I worked with. Visual Studio 2013 Express found the fltkd.lib file and the code worked.

In my case, the correct route was C: \ Program Files (x86) \ Windows Kits \ 8.1 \ Lib \ winv6.3 \ um \ x86

I do not know how to set this route inside Visual Studio.

Not sure if this Windows kits folder was created when I installed the Microsoft Windows SDK for Windows 7 and the .NET Framework 4 (ISO) http://www.microsoft.com/en-us/download/details.aspx?id= 8442

I hope that people will help you.

0
Dec 14 '13 at 3:29
source share

I just had the same problem. Exe was still working with me, but I could not finish it using the task manager. Just restarting VS, it worked for me.

0
Mar 31 '16 at 12:19
source share

My point is that if you set the option to select the MASM file, then this will give you this error.

Just use

  Enable Assembler Generated Code Listing Yes/Sg Assembled Code Listing $(ProjectName).lst 

this is normal.

But you have no additional problems.

0
Oct. 15 '17 at 4:40
source share

This usually means that your program is blocked and may not be killed through the task manager or the process guide. I met a similar case where my program had an exception while running and ran a Windows error report that blocked the program. In the event that the Windows error report blocks the program, you can go to the control panel-> System and Security-> Action Center-> Problem Report Settings to set it to "Never check solutions." Hope this helps,

-one
Sep 16 '15 at 2:57
source share



All Articles