0

I am using Visual studio 2015 Community.

When I first start without debugging (CTRL + F5) it works fine. After I click X (close the windows) and click again (CTRL + F5). I get this error:

error

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Five0
  • 11
  • 2
  • 4
  • 1
    You need to add your code to the post. Otherwise it is impossible to see what's wrong. – Sefe Dec 19 '16 at 12:58
  • The error is very clear, the files are already in use, are you sure your program has really finished? – Gusman Dec 19 '16 at 12:58
  • If you dont add your code, is very difficult te see what's going wrong. But I seems you are opening those files (.ldf) and you are not closing them, so those files are not being released. Try to see if the processes are still running in the Task Manager. – Facundo La Rocca Dec 19 '16 at 13:02
  • @FacundoLaRocca yes,processes are still running in the Task manager after I close the forms. – Five0 Dec 19 '16 at 13:25
  • @Sefe I would add the code,but there are many forms,with 400 rows of code. – Five0 Dec 19 '16 at 13:25
  • Your log system is broken or poorly concieved or not well configured, thus it isn't stopped at the end of the application. You need to dispose it on app exit – yan yankelevich Dec 19 '16 at 13:39
  • @ShendFive, what are you using those .ldf files for? Ldf files should be closed or your proccess won't be able to be closed. Add the code where ldf files are being used. – Facundo La Rocca Dec 19 '16 at 15:01
  • Possible duplicate of [Error: Cannot access file bin/Debug/... because it is being used by another process](http://stackoverflow.com/questions/11646047/error-cannot-access-file-bin-debug-because-it-is-being-used-by-another-proc) – rene Dec 19 '16 at 16:06
  • ldf and mdf files are SQL Server data files (mdf is the master data file and ldf is the log data file). The process that is likely using them is SQL Server itself. Once you connect to the database the files will be in use. Ideally you wouldn't copy over top of those files each time you build because you'll be wiping out any data you created on your last run. – Craig W. Dec 21 '16 at 23:03

2 Answers2

1

It looks like your application hasn't terminated fully and your assembly is still running.

When you build your project, msbuild cannot remove/copy your assembly into the build target folder because it is still occupied.

GDS
  • 1,337
  • 12
  • 18
1

I faced a similar issue.This is because VS locks your file before building, and sometimes the application does not close properly. So, the lock that's been provided to help build locks itself, showing build errors.

The simplest way would be to restart your Visual Studio/system to close all the threads. OR Build the application in Release mode(make sure you set your configurations right before building as per your requirement) OR Close all the Designer Windows and try again.

priyalsoni
  • 49
  • 9