strange problem....

  • Thread starter Thread starter Erland
  • Start date Start date
E

Erland

Hi there,
I am using Visual Studio 2003 and trying to write an windows
application in C#. Whenever i run my program , it runs normally and i
close it. Sometime later, i try to run the program with Ctrl+F5 and i
get following errors
i)-Could cope temporary files to the output directory.
ii)-The file 'TestApp.exe' can't be copied to the run directory. The
process can't access the file because it is being used by another
process.
iii)-The file 'TestApp.pdb' can't be copied to the run directory. The
process can't access the file because it is being used by anopther
process.

Now open my Windows Task Manager, and goto the process and i find
'TestApp.exe' in the process and i close it from there and then try to
run my applicatoin and it runs. However next time i run my application
i get same errors and i goto Task Manager and goto the process and
delete it from there and then run the application. I have been moving
in this loop for all day along. Is there a way around? What i am doing
wrong?
Please enlighten me...
-Erland
 
Erland said:
Hi there,
I am using Visual Studio 2003 and trying to write an windows
application in C#. Whenever i run my program , it runs normally and i
close it. Sometime later, i try to run the program with Ctrl+F5 and i
get following errors
<snip>

Do you have threads in your application which isn't marked as background
threads?
 
Nops im not using threads.
However, im creating a new form over a button in another form by using
following

this.Hide();
newform =new Form2();
newform.Show();
Thanks.
 
Erland said:
Nops im not using threads.
However, im creating a new form over a button in another form by using
following

this.Hide();
newform =new Form2();
newform.Show();
Thanks.

Ah, it's only when you close the "main form" that the program closes. If
you haven't found it by now, try adding an event handler on the Form2
that also closes the main form, something like this (before the .Show()
call):

newform.FormClosed += new FormClosedEventHandler(ChildFormClosed);

....

void ChildFormClosed(object sender, FormClosedEventArgs e)
{
Close();
}
 
Back
Top