King_Leo5

Hi.

This error is really annoying me because i cannot work out what is causing it. I am new to .Net and i am making a chess program in it. However, the first time i press F5 to run it it works fine but once i locse the form and then try and try F5 again i get this error:

>LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

If i go to the .exe n the folder it says and try and delete it manually it wont let me.

Please can you help.

Thanks

King Leo



Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

einaros

I guess your application is still running. Verify this in the task manager. Make sure you actually exit the application properly / cleanly, when the main form is closed.

If it's not still running, see if its being hugged by your antivirus / anti-spyware software.





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

That is what i was thinking. I thought i was exiting properly - by pressing the X in the top right. How can i tell if it is still runnning in task manager

It seems to be that it runs fine until i change the code. Even adding in another comment triggers this





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

einaros

Look for the .exe name in the task manager. You can also download the "handle" utility off sysinternals.com, and run that from the command line with the .exe's path and name as parameter. That will tell you which application keeps the file locked.





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

nobugz

Two basic reasons your app keeps running when you close its main form:
- You're using Application.DoEvents() and not exiting the loop
- You've started a Thread whose IsBackground property isn't set to true.





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

I am not doing either of these Nobugz. I will download the tool later tonight if i get time and get back to you tomorrow. Thanks to both of you so far





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

I used "handle" and found that you were correct the VCexpress.exe that still has a hold on it. However i cannot see why im not using any advanced code (i think). Also i double checked the program will let me keep running and stopping the program as many times as i want until i change the code. Even adding a comment seems to stop me from being able to run the program again.

Can you think of anything i am doing wrong or that will help

Thanks

KingLeo





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

Bite Qiu - MSFT

King_Leo5 wrote:

I used "handle" and found that you were correct the VCexpress.exe that still has a hold on it. However i cannot see why im not using any advanced code (i think). Also i double checked the program will let me keep running and stopping the program as many times as i want until i change the code. Even adding a comment seems to stop me from being able to run the program again.

Can you think of anything i am doing wrong or that will help

Thanks

KingLeo

Hi KingLeo,

Could you show us the main() function of your project

To the behavior you described above, it is because IDE is just smarter than you think, it runs existing Chess.exe if it detected that nothing changed(even no comment added) from last successful build when you click Build on project menu, and it can be run as many times as you want just like you can start as many IE as you want. When you make changes to your code, IDE will rebuild that part of code and tring to generate a new Chess.exe to overwrite existing Chess.exe, but as you have mentioned, VCexpress.exe hold a handle on it, hence "LNK1104: cannot open file".

You have not explicity answerred Einar's question, does Chess.exe still exist in task manager after you close form I believe this is very important to your problem, and you need to figure out why Chess.exe still exist after you click 'X' button, main() function may have some hints, you can also use debugger to check what is still running there. A workaround could be use pre-link event to kill all Chess.exe, but this is not a solution.

regards,

rico






Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

Hi again,

Here is the Main()

[STAThreadAttribute]

int main(array<System:Tongue Tiedtring ^> ^args)

{

// Enabling Windows XP visual effects before any controls are created

Application::EnableVisualStyles();

Application:Tongue TiedetCompatibleTextRenderingDefault(false);

// Create the main window and run it

Application::Run(gcnew Form1());

return 0;

}

and no the Chess.exe is not in the task manager after clicking the X





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

Any ideas guys





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

einaros

Chess.exe isn't in the task manager list, but 'handle' shows Visual Studio hogging it





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

yeah





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

einaros

Is the debugger still active Do you need to hit the stop button to continue editing the source





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

King_Leo5

no. i just press the X and it lets me edit again





Re: Visual C++ Express Edition >LINK : fatal error LNK1104: cannot open file 'C:\Documents and Settings\Math\My Documents\C++\Chess\Release\Chess.exe'

einaros

Then I've got no idea why VS should still hold it. Does it remain so if you let it hang for a few minutes